问题
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