Reputation: 473
I have a ember-data model (parent) that has several embedded models as properties. When I update the embedded models hasMany array the parent does not go to updated/dirty state. How can I manually send the parent to a dirty state?
I have tried the following without luck:
parent.set('isDirty', true);
parent.get('stateManager').goToState('dirty')
parent.get('stateManager').goToState('updated.uncommitted')
Upvotes: 4
Views: 2054
Reputation: 1637
If you're using Ember data
(v1.0.0 > x).
parent.get('stateManager').goToState('updated')
Isn't working anymore. Now you should use:
parent.transitionTo('updated');
These is the hierarchy of valid states that ship with ember data:
* root
* deleted
* saved
* uncommitted
* inFlight
* empty
* loaded
* created
* uncommitted
* inFlight
* saved
* updated
* uncommitted
* inFlight
* loading
Upvotes: 0
Reputation: 473
Finally found the solution my self:
parent.get('stateManager').goToState('updated')
I should also mention that when adding a belongsTo association to the child the parent will be dirtied if the hasMany association is changed. But I still need the manual dirting for the case that a normal property of the child changes.
Upvotes: 5