mardi 12 juin 2018

ember rollback attributes when user cancel the edit action

I have an app in which user can edit a product and make some changes. When user clicks the edit button, then it opens up a dialog. User can go through multiple windows and do some changes. After which, user can click save or cancel the edit action. In case of cancelling the action, I want to rollback the dirty attributes. I am using below code to do the same but somehow, some of the changes do get rollbacked while other don't. Can anyone point out if their is an issue? (below is my code for reference)

cancelAction() {
 if (this.get('isEditMode') && this.get('model').get('hasDirtyAttributes')) {
   this.get('model').send('becomeInvalid');
   this.get('model').rollBackAttributes();
}




Aucun commentaire:

Enregistrer un commentaire