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

Cannot set value on a nested has-many collection #40

Open
jamesarosen opened this issue Mar 30, 2012 · 1 comment
Open

Cannot set value on a nested has-many collection #40

jamesarosen opened this issue Mar 30, 2012 · 1 comment

Comments

@jamesarosen
Copy link
Collaborator

Example:

Klass = Em.Resource.define({
  schema: {
    children: {
      type: Em.ResourceCollection,
      itemType:Object,
      nested: true
    }
  }
});

k = Klass.create({});
k.set('children', [ { name: 'Harold' } ]);
k.get('children'); // undefined
@jamesarosen
Copy link
Collaborator Author

I believe the following works:

Ember.Resource.HasManyNestedSchemaItem.reopen({
  setValue: function(instance, value) {
    var data = this.data(instance);
    if (!data) return;

    if (Em.isArray(value)) { value = value.toArray(); }

    Ember.Resource.deepSet(data, this.get('path'), value);
  }
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant