Skip to content

Instantly share code, notes, and snippets.

@swallentin
Created September 20, 2012 05:55
Show Gist options
  • Save swallentin/3754182 to your computer and use it in GitHub Desktop.
Save swallentin/3754182 to your computer and use it in GitHub Desktop.
Backbone.js ViewTtemplate using Handlebars for templating.
var TodoView = Backbone.View.extend({
tagName: "li",
initialize: function(options) {
_.bindAll(this, "edit");
this.template = Handlebars.compile(options.template || "");
},
render: function() {
$(this.el).html(this.template(this.model.toJSON()));
return this;
},
events: {
"click a.edit": "edit"
},
edit: function() {
this.$("h2").fadeOut();
this.$("input.edit").fadeIn();
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment