Skip to content

Instantly share code, notes, and snippets.

@swallentin
Created September 20, 2012 05:56
Show Gist options
  • Save swallentin/3754186 to your computer and use it in GitHub Desktop.
Save swallentin/3754186 to your computer and use it in GitHub Desktop.
Backbone.js ListView template using Handlebars for templating.
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