What is the difference between the properties “id” and “cid” on a model object in Backbone Js?

devquora
devquora

Posted On: Feb 22, 2018

 

The “id” property on a model is automatically assigned based on the “id” set in the model’s attributes hash.

Ideally, this is the ID that you receive from the rest API for the resource that you are querying. On the other hand, “cid” is an ID temporarily assigned to each model and is useful until an actual ID is determined for the object. For example, a model pushed to a collection that has not yet been persisted can be addressed using “cid”, until it is saved in the database and an actual ID is generated for it.

    Related Questions

    Please Login or Register to leave a response.

    Related Questions

    Backbone js Interview Questions

    Explain what is Backbonejs?

    Backbone.js is a client-side (Model, View, Controller) MVC-based JavaScript framework.It purely is written in Javascrip..

    Backbone js Interview Questions

    List Dependencies of using BackboneJs?

    Backbone’s Js only hard dependency is Underscore.js ( >= 1.8.3). For RESTful persistence and DOM manipulation with..

    Backbone js Interview Questions

    What is the use of BackboneJS route?

    The Backbone.js router is used to change the URL fragment or hashes of an application to create bookmarkable and shareab..