Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation Update Request: idAttribute when using es6 based models #4219

Open
gstreetmedia opened this issue Jul 9, 2019 · 1 comment

Comments

@gstreetmedia
Copy link

When using an ES6 class, idAttribute should be returned from a getter, rather than being set in the preinitialize function.

class Meal extends Backbone.Model(
  get idAttribute() {
     return "_id";
  }
);

Otherwise the following will not work.

let model = MealCollection.get(someId);

Due to the use of prototype in the collection function

// Define how to uniquely identify models in the collection.
modelId: function(attrs) {
  return attrs[this.model.prototype.idAttribute || 'id'];
};
@jgonggrijp
Copy link
Collaborator

Closely related to #3560 and #4245.

@jgonggrijp jgonggrijp added this to Low priority in Dusting off Jan 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Dusting off
Low priority
Development

No branches or pull requests

2 participants