Revert change to ember data model

outside2344 picture outside2344 · Jun 7, 2012 · Viewed 7.1k times · Source

Is there a way to revert a change to an Ember Data model easily?

I have a model bound to an edit view. This view enables the user to cancel editing, at which point I'd like to revert the changes to the model. Is there an easy way to do this without cloning all the values off the side?

Answer

froskos picture froskos · Jan 29, 2016

Starting from Ember Data version 2, there are not transactions anymore, but you can reset models to their last status before saved editions with:

model.rollbackAttributes();