Created
September 20, 2012 05:55
-
-
Save swallentin/3754182 to your computer and use it in GitHub Desktop.
Backbone.js ViewTtemplate using Handlebars for templating.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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