VOOZH about

URL: https://www.geeksforgeeks.org/javascript/backbone-js-reset-collection/

⇱ Backbone.js reset Collection - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Backbone.js reset Collection

Last Updated : 21 Jul, 2022

The Backbone.js reset Collection is used to replace the whole list of models with a new list of models or attributes hash. This function returns newly set models in the collection. We can pass null in place of models to make the collection empty.

Syntax: 

collection.reset( models, options );

Parameters: 

  • models: This parameter specifies the instance of model and array of models which will be added to the collection in place of old models. 
  • options: This parameter specifies the optional model which is going to add to the collection.

Example 1: In this example, we will illustrate The Backbone.js reset Collection. We will add a new instance of a model which will replace the old models in the collection.

Output:

👁 Image
Backbone.js reset Collection

Example 2: In this example, we will use null in place of the new model to make the collection empty.

Output:

👁 Image
Backbone.js reset() Collection

Reference: https://backbonejs.org/#Collection-reset

Comment