VOOZH about

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

⇱ Backbone.js parse Collection - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Backbone.js parse Collection

Last Updated : 28 Jul, 2022

The Backbone.js parse Collection is a method that is called by Backbone whenever a Collection's models are returned by the server. The default implementation simply passes the JSON response. We can override it with a new logic to flexibly parse the response. 

Syntax: 

collection.parse( response , options );

Parameters:

  • response: It is a raw object which contains data regarding the request to the server.
  • options: These are the optional parameter regarding the response to the request.

Example 1: In this example, we will illustrate the Backbone.js parse Collection. Here we will parse our Models when we pass them to the collection at the initiation of collection.

Output: 

👁 Image
Backbone.js parse Collection

Example 2: In this example, we will parse the data which is coming as a result of the fetch request. 

Output:

👁 Image
Backbone.js parse Collection

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

Comment