改变路线动态片段后的视线 [英] Rerender view after change route's dynamic segment
问题描述
问题是:意见重新展现。我猜这是因为只有模型改变 - 不是UI。但是我在视图中有一些UI逻辑'didInsertElement处理程序 - 重新初始化UI插件等等。
如何强制ember在动态段更改后重新渲染视图?
我同意josh的评论。如果您使用动态段落更改视图,则表示您的代码未正确写入。但是,如果你想要这样做,我会给的是代码的一部分。
在你的路线:
模型:function(params){
model.set('id',params.id);
}
在您需要重新呈现的视图中:
_modelIdChange:function(){
this.rerender();
} .observes('controller.model.id')
但是我不建议这个。我宁愿更喜欢正确的绑定。但是在某些情况下,我确实使用了rerendering,主要是当你最终使用jQuery插件时。
I have a Route with dynamic segment :id. When I change only the dynamic segement part manually in browser url input field, then goes a transition, and all model hooks are called as expected.
The problem is: none of the views are rerendered. I guess it is because only model changed - not the UI. But I have some UI logic in views' didInsertElement handler - reinitialize UI plugins and so on.
How to force ember to rerender view after dynamic segment change?
I agree with the josh's comment. if you are rerendering views with the change of dynamic segment means your code is not written properly. But still if you want to go like that i am gonna give is a part of code.
In your route:
model: function(params){
model.set('id', params.id);
}
In your view which needs to be rerendered:
_modelIdChange: function(){
this.rerender();
}.observes('controller.model.id')
But i don't suggest this. I would rather prefer proper bindings. But i did use rerendering in some cases which mostly when you end up using jquery plugins.
这篇关于改变路线动态片段后的视线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!