Created
February 23, 2015 12:53
-
-
Save stephendeyoung/89f7537558a83f72ea1f to your computer and use it in GitHub Desktop.
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
Marionette.CollectionView.extend({ | |
initialize: function(options) { | |
this._initChildViewStorage(); | |
this.childView = this.childView || options.childView; | |
this.createChildren(options); | |
this._initialEvents(); | |
}, | |
createChildren: function(options) { | |
this.collection.each(function(model) { | |
var childViewOptions = typeof this.childViewOptions === 'function' ? this.childViewOptions(model, options) : {}; | |
var view = new this.childView(_.extend({ | |
el: options.selector(this.$el.selector, model.get('_id')), | |
model: model | |
}, childViewOptions)); | |
this.initializeChild(view); | |
}, this); | |
}, | |
initializeChild: function(view) { | |
this.proxyChildEvents(view); | |
this.children.add(view); | |
if (view.onRender) { | |
view.onRender(); | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment