Ember data: manually send the model to an updated state

I have an ember-data (parent) data model that has several built-in models as properties. When I update the hasMany built-in models, the parent element does not go into an updated / dirty state. How can I manually send a parent to a dirty state?

I tried the following with no luck:

parent.set('isDirty', true); parent.get('stateManager').goToState('dirty') parent.get('stateManager').goToState('updated.uncommitted') 
+4
source share
2 answers

If you are using Ember data (v1.0.0> x).

 parent.get('stateManager').goToState('updated') 

Does not work any more. Now you should use :

 parent.transitionTo('updated'); 

This is a hierarchy of valid states that are sent with ember data:

 * root * deleted * saved * uncommitted * inFlight * empty * loaded * created * uncommitted * inFlight * saved * updated * uncommitted * inFlight * loading 

State Suppression

0
source

Finally, I found the solution myself:

 parent.get('stateManager').goToState('updated') 

I should also mention that when adding the belongsTo association with the child, the parent will become dirty if the hasMany association is changed. But I still need a hand-made garland for the case of changing the normal properties of the child.

+5
source

Source: https://habr.com/ru/post/1413024/


All Articles