What approach would be more efficient?
I have a Backbone.Collection so i Create a Backbone.View to render this collection. The CollectionView render method:
container = document.createDocumentFragment()
@collection.each (item) ->
view = new ItemView(item)
I can use the events in two forms.
1.- Set the events object in CollectionView, so i need to declare the action of select an item in the CollectionView and "rescue" the model that i selected.
CollectionView extends Backbone.View
'click #itemView', 'onSelectItem'
##Get the model
2.- Set the events object per itemView, so the select method don't need to retrieve the model.
ItemView extends Backbone.View
Which of this options are better?
JSperf snippet http://jsperf.com/backbone-events-on-collectionview-or-per-itemview to test this
JSperf show us that the ItemView approach have a better performance and is more "intuitive" use items events in each ItemView.