Reputation: 21564
https://github.com/marionettejs/backbone.marionette/blob/master/docs/marionette.view.md
In this example:
<script id="my-template" type="text/html">
I think that <%= showMessage() %>
</script>
MyView = Backbone.Marionette.ItemView.extend({
template: "#my-template",
templateHelpers: {
showMessage: function(){
return this.name + " is the coolest!"
}
}
});
model = new Backbone.Model({name: "Backbone.Marionette"});
view = new MyView();
view.render(); //=> "I think that Backbone.Marionette is the coolest!";
I've tried analyzing this code and based on my understanding of Backbone, you have to specify which model the view is associated with. I tried understanding Marionette views and I don't know which part of the docs or in this example shows how the view knew that this
refers to the newly created model. Or is this just a typo?
Upvotes: 0
Views: 1370
Reputation: 72868
There's an error in that example. It should show this:
model = new Backbone.Model({name: "Backbone.Marionette"});
view = new MyView({
model: model
});
view.render(); //=> "I think that Backbone.Marionette is the coolest!";
I'll update the docs to fix this
Upvotes: 1