Chapter 4. Working with Collections
The purpose of the Backbone collection is pretty straightforward. As an ordered set of models, a collection provides a number of useful methods to play around with, including a set of Underscore.js utility methods. A collection includes functionality to add, remove, sort, and filter models, and save to or fetch data from the server. A collection listens to the events fired on its models–if an event is fired on a model of a collection, it will also be fired on the collection itself. This facility is quite significant when you want to listen to an attribute-change event of the model. We will look into it using some examples in the Basic usage of collections section of this chapter.
In the previous chapters, we saw a number of implementations of a simple collection to display multiple items in a list view. However, there can be cases where you want to sort the list with a number of criteria or you want to filter the list items to show only a particular type...