Skip to content

Instantly share code, notes, and snippets.

@stevenpsmith
Created December 22, 2011 17:44
Show Gist options
  • Save stevenpsmith/1511157 to your computer and use it in GitHub Desktop.
Save stevenpsmith/1511157 to your computer and use it in GitHub Desktop.
exercise.ActivityListView = Backbone.View.extend({
tagName: 'ul',
id: 'activities-list',
attributes: {"data-role": 'listview'},
initialize: function() {
this.collection.bind('add', this.render, this);
this.template = _.template($('#activity-list-item-template').html());
},
render: function() {
var container = this.options.viewContainer,
activities = this.collection,
template = this.template,
listView = $(this.el);
$(this.el).empty();
activities.each(function(activity){
listView.append(template(activity.toJSON()));
});
container.html($(this.el));
container.trigger('create');
return this;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment