Home » Backbone.js collection.set()

Backbone.js collection.set()

by Online Tutorials Library

Backbone.js collection.set()

The backbone.js collection set method performs a smart update of the collection with a set of items in the model. If a model in the list isn’t yet in the collection it will be added; if the model is already in the collection its attributes will be merged.

Syntax:


Parameter explanation:

models: It specifies an instance of the collection along with values to be set in the collection.

options: It contains parameters such as id, name etc. to set the values in the collection.

Let’s take an example.

See this example:

You may also like