Skip to content

Instantly share code, notes, and snippets.

@headwinds
Created November 25, 2013 16:07
Show Gist options
  • Save headwinds/7643781 to your computer and use it in GitHub Desktop.
Save headwinds/7643781 to your computer and use it in GitHub Desktop.
a sample from my tutorial on the Marionette CollectionView
// see https://github.com/headwinds/tutorials/tree/master/marionettejs/marionettejs-collection-view
define([
'underscore',
'backbone',
'marionette',
'views/user/UserItemView',
'models/user/UserModel',
'collections/user/UserCollection'
], function(_, Backbone, Marionette, UserItemView, UserModel, UserCollection ) {
var UserCollectionView = Backbone.Marionette.CollectionView.extend({
el: "#users",
tagName: "tbody",
itemView: UserItemView,
onAfterItemAdded: function(itemView){
//console.log(itemView.model, "UserCollectionView - item was added");
},
onRender: function(){
var that = this;
that.children.each(function(view){
// you can also loop through items here...
});
}
});
return UserCollectionView;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment