余烬.制作具有自己路线的模态视图 [英] Ember. Making modal view that has its own route

查看:32
本文介绍了余烬.制作具有自己路线的模态视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想制作一个模态视图,可以通过其自己的路径访问.

I want to make a modal view that can be accessible by its own route.

问题是-我想在我的应用程序的其他状态/视图/路由顶部显示此视图,该视图/路由内部已计算出大数据.

The problem is — I want to show this view on top of other state/view/route of my app that have big data computed inside.

我认为我可以使用嵌套路线来做到这一点.如果我们运行到子路线的过渡,则不会重新计算任何内容,只是子节目-很好.

I thought that i can do it with nested routes. If we run transition to child route, nothing will be recalculated, just child show - very good.

但是在实践中,当我尝试为某些资源添加子路径时.我遇到了此问题中所述的问题..因此,嵌套路由不是解决方案.

But on practice, when I tried to add child routes for some my resources. I meet the problem described in this question. So, nested routes is not a solution for it.

什么是解决方案?有什么想法吗?

What is solution? Any ideas?

推荐答案

我的解决方案在这里.(事实是它是带有一些作弊的嵌套路线)

My solution is here. (the fact is it's nested routes with some cheats)

1)模态进入模态"出口

1) modal goes to 'modal' outlet

2)我们为模态提供的路线名称不同,但路径部分相同.

2) we have routes for modal with different names, but with the same paths parts.

this.resource('category', { path: '/category/:category_id' }, function () {
    /* Different names for the same modal route */
    this.resource('modal1', { path: 'card/:card_id' });
});

// url - semantic/books/card/id99
this.resource('semantic', { path: '/semantic/:semantic_id' }, function () {
    /* Different names for the same modal route */
    this.resource('modal2', { path: 'card/:card_id' });
});

3)执行过渡时我们必须为父级路由传递上下文

3) when perform transitionTo we have to pass context for parent route

var curPath = this.controllerFor("application").currentPath;

if (/^category/g.test(curPath))
    this.transitionToRoute('modal1', { category_id: cat_id, card_id: card_id ) });
else if (/^semantic/g.test(curPath)) 
    this.transitionToRoute('modal2', { semantic_id: sem_id, card_id: card_id ) });              

这篇关于余烬.制作具有自己路线的模态视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆