backbone.js - Backbone Performance - Collection with a view per model or only one view for the whole collection -
if have collection 50 models, seems have 2 main options render list displaying 50 models:
- option1 : create specific "item view" each model , append these views main "list view". provide direct relationship between each "item view" , each model, practical , inline backbone philosophy
- option2 : have 1 "list view" rendering list "data-attributes" helping fetch corresponding model when event happens on given list item.
i understand option 1 leverages backbone in better way concerned number of event listeners option. if have 4 events have listen per item, mean have 4x50=200 events listeners on list... vs. 4 (delegated) events listeners option 2.
given want use backbone cordova application, option appropriate ?
maybe in case practical used "mixed" approach. view every model, event listeners on top list view delegate them further. reduces event listeners on dom elements.
despite - use per-item-views when need functionality such rendering , handling edit form, or when single items changed need re-render often. if isn't case use single list view , let handle events.
Comments
Post a Comment