Now that details of a movie can be rendered, let’s look at a more realistic movies program. When there are tens or hundreds of movies, users might want to quickly sort and filter movies, as well as paginate through a large collection of movies. Since filtering, sorting and pagination is about adding and removing models from a collection, we are going to study how to transform the structure of a Backbone collection next.
In our example of Munich Cinema, our main goal is to give users a way to quickly find an interesting movie. Especially, we want to provide basic search and filtering options for better navigation through the movie program.
The goal of this chapter is to provide an overview on:
When you read the documentation of Backbone.Collection, you will stumble upon an important piece of information to access and mutate a collection:
Backbone proxies to Underscore.js to provide 28 iteration functions on Backbone.Collection
You already saw some examples of using
map. In the sections to follow, you will learn the relevance of
First, we look at sorting movies. Sorting models is a common task for a Backbone collection. Usually, you need to define a comparator function to get the correct positions of models in a collection.
From the documentation at Backbone.js, the working of a comparator is described ...