Difference between id and cid properties on a model object in Backbone.js
Backbone.js id Model: The Backbone.js id model is utilized to locate the specific identification in a model. It can be manually set, and a server will later store it.
Parameters: It does not accept any parameter.
Example 1: The code below demonstrates how to use the id property of the model object.
Backbone.js cid Model: The Backbone.js cid Model is a unique identifier to the model. When a model is first built, it is automatically allocated to it. When we didn’t provide the model with a special identifier, Cid is helpful. Client ID is the meaning of the cid.
Parameters: It does not accept any parameters.
Example 2: The code below demonstrates how to use the cid property of the model object.
The difference between the properties “id” and “cid” on a model object:
|Based on the “id” value set in the model’s attributes hash, the “id” property on a model is automatically assigned.||The “cid” is a temporary ID given to each model that can be used until an actual ID for the item is established.|
|Once this is set it will stay fixed for the model object||This is created at first and it is temporary and gets destroyed afterwards.|
|Syntax: Backbone.Model.id||Syntax: Backbone.Model.cid|
Reference: https://backbonejs.org/#Model-id, https://backbonejs.org/#Model-cid
Please Login to comment...