Skip to content

Instantly share code, notes, and snippets.

@krusty
Created December 15, 2012 00:11
Show Gist options
  • Save krusty/4289816 to your computer and use it in GitHub Desktop.
Save krusty/4289816 to your computer and use it in GitHub Desktop.
Post.Views.Post = Backbone.View.extend({
el: '#post',
initialize: function () {
this.template = _.template($('#post-template').html());
app.on('change:post', this.render, this);
},
render: function (post) {
this.$el.html(this.template(post.toJSON()));
return this;
},
});
Post.Views.PostTitle = Backbone.View.extend({
tagName: 'li',
initialize: function () {
this.template = _.template($('#post-title-template').html());
},
events: {
'click': 'changePost',
},
changePost: function () {
app.trigger('change:post', this.model);
},
render: function () {
this.$el.html(this.template(this.model.toJSON()));
return this;
},
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment