O'Reilly logo

Backbone.js Cookbook by Vadim Mirgorod

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Binding a collection to a view

In this recipe, we are going to learn how to bind a collection to a view. This can be very helpful if we have different views working with the same collection, or if we want to synchronize data with a REST server.

Let's take an example of the Rendering a model in a view recipe from Chapter 4, Views, where we rendered a collection with subviews and modified it. We are going to add an additional view with the Add and Remove buttons, which will update the collection.

Also, we will bind appropriate callbacks to the model and collection events in our first view, so it is re-rendered automatically when the collection is changed.

When a user clicks on the Add button, he/she is prompted to enter the required information to ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required