Created
April 2, 2017 14:48
-
-
Save paulfalgout/1826e3324d004e2b5f50c28e75fcce06 to your computer and use it in GitHub Desktop.
Make a CompositeView with NextCollectionView
This file contains hidden or 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 MixinFromView = _.pick(Marionette.View.prototype, 'serializeModel', 'getTemplate', '_renderTemplate', 'mixinTemplateContext', 'attachElContent'); | |
var NextCompositeView = Marionette.NextCollectionView.extend({ | |
childView: function() { | |
return this.constructor; | |
}, | |
serializeData: function() { | |
return this.serializeModel(); | |
}, | |
getChildViewContainer: function() { | |
var selector = _.result(this, 'childViewContainer'); | |
return selector ? this.findEls(selector, this.$el) : this.$el; | |
}, | |
onBeforeRender: function() { | |
this._renderTemplate(); | |
this.bindUIElements(); | |
this.$childViewContainer = this.getChildViewContainer(); | |
}, | |
attachHtml: function(collectionView, els) { | |
this.appendChildren(this.$childViewContainer, els); | |
} | |
}); | |
_.extend(NextCompositeView.prototype, MixinFromView); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment