The PostRoute
can be modified to look for the post in the model already loaded by the PostsRoute
. If found will return it, otherwise will try to loaded it through the ajax call.
App.PostRoute = Ember.Route.extend({
model: function(params) {
var post = this.modelFor("posts").findBy("id",parseInt(params.post_id));
if(Em.isEmpty(post)){
return App.Post.find(params.post_id);
}else{
return post;
}
}
});