I'm using Marionette Views within Backbone.
In my template I would like to pull out the name attribute from my models fetched data. The model has been populated and I can see via console.log
the correct results, but when I try to output this in a template:
<script type="text/html" id="sample-template">
<h1><%= campaign ? campaign.get('name') : '' %></h1>
</script>
I get the message: campaign is not defined I have also tried attributes.get('name'), CampaginModel.get('name') and model.get('name') but get the same error
Does Marionette have a different of of doing this, if so how should I do it?
view:
var campaginView = Backbone.Marionette.ItemView.extend({
initialize: function (options) {
this.campaign_id = options.id;
this.model.fetch();
},
model: new CampaginModel({
id: this.campaign_id
}),
template: campaignTemplate,
});
console.log of model:
_changing: false
_pending: false
_previousAttributes: Object
attributes: Object
modified: "2013-11-08T18:57:44"
name: "test"
user: Object
__proto__: Object
changed: Object
cid: "c2"
__proto__: s