灰烬-使用相同模型过渡到相同路线 [英] Ember - Transition to same route with same model

查看:60
本文介绍了灰烬-使用相同模型过渡到相同路线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个左树列表,列表中的每个项目都以不同的模型打开相同的路线。我想要的是,如果我一次又一次单击同一项目,我希望路由再次加载。我知道余烬通常不会以这种方式运行。

I have a left tree list, and each item in the list opens same route with different model. What i want is, if i click on the same item again and again, i want the route to load again. I know ember doesn't normally function this way. Are there any tweaks to achieve this?

更新:
左树是父路线。单击左树中的项目时,子路线会加载到其出口中。

Update: Left tree is parent route.On clicking items in left tree, child route is loaded in its outlet.

我的左树将这样构造,

item1(链接到bodyRoute1与model1)
item2(与model2链接到bodyRoute1)
item3(与model3链接到bodyRoute1)
item4(与model1链接到bodyRoute2)
... etc

推荐答案

我是这样做的,

我在对象中维护 currentRouteName currentModelId (用于唯一标识模型的ID),它是注入所有路线。

I maintain the currentRouteName and currentModelId(An id to uniquely identify the model) in an object and it is injected in all routes. It gets updated on any transition.

从左树开始的所有转换都通过一个公共函数,在该函数中,我检查转发路由,modelId是否与当前路线,modelId。如果是这样,我将更改另一个全局注入的属性 refreshSameRoute 的值。此值在子路由中观察到,并且如果更改,则会调用 this.refresh()

All the transitions from left tree go through a common function, And in that function i check if the forwarding route,modelId is the same as current route,modelId. If so, i change the value of another globally injected property refreshSameRoute. This value is observed in the child routes and if it changes this.refresh() is called.

仍在搜索以获得更好的方法。

Still searching for a better method.

这篇关于灰烬-使用相同模型过渡到相同路线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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