-
Notifications
You must be signed in to change notification settings - Fork 30
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
Can't override getter - Maximum call stack size exceeded #30
Comments
Should work, unless Coffescript does something weird in terms of scoping... |
I'm having the same issue using vanilla JavaScript |
Same issue for me |
I think I had the same problem but solved it like this : var User = Backbone.Model.extend({
"mutators": {
/**
* Profile mutator, creates a profile model from the existing data
*
* @return {Profile} Profile model instance
*/
"profile": function() {
// /!\ Access attributes object instead of calling this.get("profile")
var profile = this.attributes.profile;
if (_.isObject(profile) && !profile.cid) {
var newProfile = new Profile();
// Check if the existing data only consists of an id or not
if (Object.keys(profile).length === 1 && profile.id) {
// Only set the id
newProfile.set("id", profile.id);
} else {
// Create profile model instance from existing data
newProfile.set(profile);
}
profile = newProfile;
this.set("profile", newProfile);
}
return profile;
}
}
}); I used mutators to implement nested model instances, but when using |
@asciidisco I believe the issue is still present in vanilla JavaScript. I've put together a simple JSFiddle here to demonstrate. The code is a straight copy-and-paste from the Backbone.Mutators docs. It throws an Maybe we could pass in the original Backbone getter as an argument to use within the mutated getter? For example, similar to how it's currently done with setters. For now, an easy workaround is to just use a different name for your mutated getter. But it would be nice to be able to use the same name as an existing model property. |
+1 same issue |
Same here |
@RasCarlito 's solution works for me +1 |
Yup, same here. Still broken. @RasCarlito 's solution does work. |
The text was updated successfully, but these errors were encountered: