2011-04-15 18:55:37 +00:00
|
|
|
var <%= object_name %>View = Backbone.View.extend({
|
2011-05-03 19:43:19 +00:00
|
|
|
events: {
|
|
|
|
'click button.save': 'save'
|
|
|
|
},
|
|
|
|
attributeFields: [],
|
2011-04-16 14:39:18 +00:00
|
|
|
template: JST['<%= underscore_name %>s/view'],
|
2011-04-15 18:55:37 +00:00
|
|
|
initialize: function() {
|
2011-05-03 19:43:19 +00:00
|
|
|
_.bindAll(this, 'render', 'save');
|
|
|
|
|
|
|
|
this.model.bind('change', this.render);
|
2011-04-15 18:55:37 +00:00
|
|
|
},
|
|
|
|
render: function() {
|
2011-04-29 19:05:54 +00:00
|
|
|
$(this.el).html(this.template(this.model.toJSON()));
|
2011-05-03 19:43:19 +00:00
|
|
|
this.$('button.save').text(this.model.isNew() ? 'Create' : 'Update');
|
2011-04-15 20:14:18 +00:00
|
|
|
return this;
|
2011-05-03 19:43:19 +00:00
|
|
|
},
|
|
|
|
save: function() {
|
|
|
|
this.model.save(this.attributes());
|
2011-04-15 18:55:37 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|