Created
September 20, 2012 05:56
-
-
Save swallentin/3754186 to your computer and use it in GitHub Desktop.
Backbone.js ListView template 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 TodoListView = Backbone.View.extend({ | |
tagName: "UL", | |
className: "todos", | |
initialize: function() { | |
_.bindAll(this, "addTodo"); | |
}, | |
render: function() { | |
this.collection.each(this.addTodo); | |
}, | |
addTodo: function(todo) { | |
var view = new TodoView({ | |
model: todo | |
}) | |
var todoEl = view.render().el; | |
$(this.el).append(todoEl); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment