Update Objects and reset the isDirty-flag (ember-data 1.0 beta.2)


[ I see this is the wrong forum, sorry - moved to http://stackoverflow.com/questions/18691337/update-objects-and-reset-the-isdirty-flag-ember-data-1-0-beta-2 ]

With former versions of ember-data I could bring a modified model back to clear-state by calling:


Is there a way to do this in version 1.0beta.2? The main reason is to suppress any server requests when saying



What about user.rollback()?

Taking the look at the source code it does exactly what you try to achieve.


@balint: thanks for the hint - u.rollback() actually reverts the changes too, but clearing the _attributes before transition

u.get('isDirty') => true

u._attributes = {}

u.get('isDirty') => false

seems to work pretty well.


So do I understand correctly that rollback() does not cut it for you because it also clears out the _attributes hash?


Not exactly - I’ll give an example of what I meant. But while I typed it I found out that this not a good solution, because by clearing out the _attributes, the object loses its ability to become dirty again permanently (ember-data 1.0 beta2).

u = App.store.all('user').objectAt(1)
u.get('isOnline') => false
u.get('isDirty') => false

u.set('isOnline', true)
u.get('isDirty') => true
u._attributes => Object {isOnline: true}

a) with rollback:
u.get('isDirty') => false
u.get('isOnline') => false

b) with clear _attributes & transition:
u._attributes = {}
u.get('isDirty') => false
u.get('isOnline') => true


ahh, this url http://emberjs.com/blog/2013/09/04/ember-data-1-0-beta-2-released.html has a solution:

"Add store.update(type, hash) to update some, but not all attributes"

That’s not really an answer to my former question - but it is exactly what I want.