You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
var hacker = new Backbone.Model({
name: "name",
idAttribute: 'nameId',
});
if (this.idAttribute in attrs) this.id = this.get(this.idAttribute);
The attribute Id has been updated, does the attribute nameId also need to be updated?
I don't think it is necessary to update the attribute id, just the nameId
I wonder if you can understand Chinese, but my English is poor
The text was updated successfully, but these errors were encountered:
@usernameisregistered If you console.log(hacker), you will find an object that looks like this:
{id: undefined,// idAttribute inherited from Backbone.Model.prototype, default 'id'attributes: {name: 'name',idAttribute: 'nameId'}// more properties}
You probably meant to do this:
// Define a new type of model which obtains its `id` from the `nameId` attribute.varHacker=Backbone.Model.extend({idAttribute: 'nameId'});// Create a new instance of the above model type.varhacker=newHacker({nameId: 'name'});
Now console.log(hacker) will output the following instead:
{id'name',idAttribute: 'nameId',attributes: {nameId: 'name'}// other properties}
backbone/backbone.js
Line 519 in 0b1c2e3
The attribute Id has been updated, does the attribute nameId also need to be updated?
I don't think it is necessary to update the attribute id, just the nameId
The text was updated successfully, but these errors were encountered: