How to "reset" the ember-data data model if it is currently dirty

I can not find the updated api for ember-data, which allows you to reset the model.

For example, I am inside my route during the willTransition action, and I think the model is dirty. I ask the user if they want to save the changes before leaving (that is, they accidentally click the "Back" button on the form randomly). If they prefer the transition anyway, I need a way to "reset" the model.

The older api mentions "removeDirtyFactors", but I'm using 1.0 beta 4+, and it looks like this is no longer the case.

FooRoute = Ember.Route.extend({ actions: function() { willTransition: function(transition) { var dirty = this.get('controller.content.isDirty'); if (dirty && !confirm("ask the user something")) { transition.abort(); }else{ return true; } } } }); 
+6
source share
1 answer

You can use this method:

 model.rollbackAttributes(); 

More details:

API Documentation

+18
source

All Articles