Last active
December 23, 2015 03:59
-
-
Save vikynandha-zz/6577627 to your computer and use it in GitHub Desktop.
Example to demonstrate too much boilerplate code while in Backbone.
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
var AnyCollectionView = Backbone.View.extend({ | |
initialize: function() { | |
this.collection.on( 'add', this.appendItem, this ); | |
}, | |
render: function() { | |
this.$el.empty(); | |
this.collection.each( this.appendItem, this ); | |
return this; | |
}, | |
appendItem: function( model ) { | |
this.$el.append( new AnyModelView({ | |
model: model | |
}).render().$el ); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment