What is the difference between 1,model Id,idattribute and CID?
A: Both CID and ID are unique identifiers of model, and either can be used to return a model from collection.
The CID stores the client unique identity that Backbone.js has assigned to the model, and in some cases (such as new data), your object has not yet been stored in the database, and the model does not have a unique identity, but the client generates a CID for it, at this point, at the client's point of view, this m There is no difference between Odel and other similar model, so that the front-end code can easily handle this type of model without regard to special cases.
Ideally, we hope that the server uses the server-side identity, the client uses the client's identity
However, if the data needs to interact with the server, it is necessary to establish a correspondence between the two-party data, which is the function of the ID. The ID stores the unique identity of the data on the server, such as the server's primary key called "id", which can be used to update the data on the server model when the client model is updated.
However, our server model's primary key is named by the server developer, not necessarily called "id" (good annoying), then, the client should be able to specify the model ID corresponding to the server model of which the primary key, then the birth of Idattribute is taken for granted.
Three combination, let the front-end code more convenient, clear, have to say, this design is very ingenious.
Learn some doubts in the backbone