I’d like to display specific elements in my template if my model is new vs existing.
I tried to show {{ id }}, {{ cid }} and {{ isNew }} but all of them are empty.
Here’s the examples :
// The Model
var MyModel = Backbone.Model.extend({});
// In the view
var model = new Contact();
this.$el.empty().append(this.template(model.toJSON()));
// The template :
{{#if isNew}}New model{{/if}}
How can I test ?
Here’s the solution I come up with :
Of course, this ensure that this model does not have the attribute “isNew” 😉