【发布时间】:2015-10-27 18:25:18
【问题描述】:
我有两个嵌套路由,projects 和 projects/project。每当我打开project 时,我都希望刷新projects 路由。
我所知道的是在setupController 钩子期间调用控制器函数(最终将在projects 路由中调用refresh)。像这样的:
// project route
setupController: function(controller, model) {
this.controllerFor('projects').send('search');
controller.set('model', model)
}
// projects controller
actions: {
search: function() {
// do other things
this.send('refreshModel');
}
}
// projects route
actions: {
refreshModel: function() {
this.refresh();
}
}
问题是,当refresh函数被调用时,它不仅刷新了当前路由,还刷新了所有子路由,这意味着这个setupController钩子会再次被执行,造成这个无限循环。
有没有办法让 Ember 只刷新当前路由,而忽略其子路由?
谢谢。
【问题讨论】:
标签: ember.js