Ember.js: Prevent destroying of views

Deadly 提交于 2020-01-05 04:51:48

问题


I have my routes setup like this:

this.resource('post',{path:":post_id"},function(){
    this.resource('selectimage',{path:"selectimage/:returncontext"},function(){    });
});

Both post.index and selectimage are rendered into separate outlets:

// PostIndexRoute
renderTemplate: function (controller) {
    this.render({ outlet: 'detailColumn' });
},

// SelectimageRoute
renderTemplate: function (controller) {
    this.render({ outlet: 'modal' });
},

When I navigate from post to post/selectimage, the post.index view is destroyed ("willDestroyElement" is called). And when I navigate back to selectimage post.index needs to be re-rendered.

Can I prevent this behavior and just keep the views in place until I really leave the post resource?


回答1:


Don't use the Index route under post, just use the PostRoute/PostController/Post template instead, those won't be destroyed when you visit resources below them.

Essentially the index route is a different path than the selectimage path, so it's removed when you navigate there.



来源:https://stackoverflow.com/questions/19956885/ember-js-prevent-destroying-of-views

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