I don't understand Ember {{render}} explanation when it comes to the model (http://emberjs.com/guides/templates/rendering-with-helpers/). What is "singleton instance of the corresponding controller"?
When no model is provided it gets the singleton instance of the corresponding controller
When a model is provided it gets a unique instance of the corresponding controller
I am trying to embed a view on a page. I have a Post page that I want to embed Comments/New in the Post page so that I can comment on the Post page.
I can go to comments/new and add a new comment. But when I try to embed in the Post page using {{render}}, it has errors because it does not include the CommentsNewRoute logic.
The problem is that I have logic in CommentsNewRoute, but it appears that when I use {{render}} it ignores the Route logic. How can I get {{render}} to just use the corresponding Route logic?
CommentsNewRoute:
App.CommentsNewRoute = Ember.Route.extend({
model: function(){
return this.store.createRecord('comment');
},
actions: {
willTransition: function(transition) {
if (this.currentModel.get('isNew')) {
this.get('currentModel').deleteRecord();
};
}
}
});
CommentsNewController:
App.CommentsNewController = Ember.ObjectController.extend({
actions: {
save: function() {
// do save new comment stuff
}
}
});
Post/Index .hbs template:
<h1 class="page-header">Post {{id}}</h1>
{{render "comments/new"}} <<<<<< I want to embed the whole Comments/New page here, including the logic from CommentsNewRoute
Router:
this.resource('post', { path: '/posts/:id' }, function() {
this.route('edit');
});
this.resource('comments', { path: '/comments' }, function() {
this.route('new');
});
Version:
DEBUG: ------------------------------- ember.js
DEBUG: Ember : 1.6.0-beta.5 ember.js
DEBUG: Ember Data : 1.0.0-beta.8.2a68c63a ember.js
DEBUG: Handlebars : 1.3.0 ember.js
DEBUG: jQuery : 1.11.1 ember.js
DEBUG: -------------------------------