Rerender view after change route's dynamic segment

落爺英雄遲暮 提交于 2019-12-24 15:12:29

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/25065754/rerender-view-after-change-routes-dynamic-segment

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!