简体   繁体   中英

Binding collections to views in Backbone.js

I am new to backbone and I am stuck with this problem where I need to bind a Collection to a view. Is there a way to do this in Backbone or do I have to iterate through my Collection and then bind individuals models to views? All the examples I found online go through these lines of iterating through the collection (like http://liquidmedia.ca/blog/2011/02/backbone-js-part-3/ ).

If this is the way to do it in Backbone, then my other question is whether there is another framework that does a better job for binding to Collections.

Thanks

All model events are delegated to the collection as well. So instead of binding to each models change event you could just bind to the collections change event. Whenever a model changes the collection triggers the event as well and gives you the model that triggered the event as callback argument.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM