Search code examples
ember.jsember-model

Is there a way to perform rollback in ember-model?


I am trying to set up a some simple CRUD operations using ember-model. While editing a model in my app, I want there to be a "cancel edit" option. This should undo any changes that where made to the data, even if they were not saved to the store.

I know that with ember-data I could simply call "model.rollback()" but I do not see a way to do this with ember-model. Is there a way to achieve this functionality with ember-model?

Basically, how would you turn this code that works with ember-data into something I can use with ember-model?

cancelEdit: function() {
    this.get('model').rollback();
    this.set('isEditing', false);
}

Also this is the first question I have asked on this site so any tips for the proper way to ask questions would be welcome


Solution

  • In Ember model the function name is revert

    model.revert();