Book Image

Backbone.js Patterns and Best Practices

By : Swarnendu De
Book Image

Backbone.js Patterns and Best Practices

By: Swarnendu De

Overview of this book

Table of Contents (19 chapters)
Backbone.js Patterns and Best Practices
About the Author
About the Reviewers
Precompiling Templates on the Server Side


Working with collections is a basic requirement of Backbone, and the questions associated with a collection are related to the models too. For example, the most common issue that almost every developer faces is nested collections, and the solution to the problem is related to how the data is parsed inside the model itself. We discussed the relational data plugin in Chapter 3, Working with Models, that wonderfully solves the problem with nested models and collections. It is highly recommended to use this plugin for any such data relationships.

This chapter discussed how we can sort and filter collections. Simple sorting and multiple sorting processes were described with examples. We also saw a number of methods for filtering a collection, which can be useful in different situations.

A collection can hold different types of model data inside—the solution to which was described with an example. In general, any dataset needs a handful of utility methods to work with. A large set of Underscore...