# How to cancel model changes without using emberdata

**URL:** <https://discuss.emberjs.com/t/how-to-cancel-model-changes-without-using-emberdata/8580>\
**Category:** Uncategorized\
**Created:** [August 14, 2015, 6:45pm UTC](https://discuss.emberjs.com/t/how-to-cancel-model-changes-without-using-emberdata/8580 "2015-08-14T18:45:42Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![square](https://avatars.discourse-cdn.com/v4/letter/s/49beb7/32.png) [@square](https://discuss.emberjs.com/u/square)\
**Post date:** [August 14, 2015, 6:45pm UTC](https://discuss.emberjs.com/t/how-to-cancel-model-changes-without-using-emberdata/8580/1 "2015-08-14T18:45:42Z")

</div>

I have a screen where I can edit my ‘Florida’ model (this can be any state). How can I undo my changes to the model and transition back to Florida (I’m not currently using emberdata)?

If I simply do a transitionTo, the changes are still in my model.

This is what my url looks like:

[http://localhost:4200/editor/state/florida/edit](http://localhost:4200/editor/state/florida/edit)

---

<div class="post-metadata">

**Author:** ![bognix](https://avatars.discourse-cdn.com/v4/letter/b/df705f/32.png) [@bognix](https://discuss.emberjs.com/u/bognix)\
**Post date:** [August 17, 2015, 9:39am UTC](https://discuss.emberjs.com/t/how-to-cancel-model-changes-without-using-emberdata/8580/2 "2015-08-17T09:39:26Z")

</div>

I stumble upon similar problem and I fixed it by passing deep copy of model to component. On ‘save’ click I am replacing existing model with copied one and on ‘back’ click I am doing nothing (only transition). I’m not sure if it’s “the ember way” but it worked for me.

I would love to hear some ember magician to tell me how it should be done in ember way.

---

<div class="post-metadata">

**Author:** ![square](https://avatars.discourse-cdn.com/v4/letter/s/49beb7/32.png) [@square](https://discuss.emberjs.com/u/square)\
**Post date:** [August 17, 2015, 6:56pm UTC](https://discuss.emberjs.com/t/how-to-cancel-model-changes-without-using-emberdata/8580/3 "2015-08-17T18:56:22Z")

</div>

[Mike had a good point about Obervables](http://stackoverflow.com/questions/32017613/how-to-cancel-model-changes-without-using-emberdata) so I’m not sure if using a copy of the model is a good idea.

What I ended up doing is:

```
cancel: function() {
      this.transitionTo('editor.state', this.modelFor(this.routeName).path + '?');
}

```

By appending the ‘?’, it caused my state route’s model hook to fire and do another lookup (which is what I want). I’m still curious if there is a more ‘ember’ way to do this without performing another call to my api.

My above solution still didn’t work.

---

<div class="post-metadata">

**Author:** ![Panman8201](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/panman8201/32/17727_2.png) [@Panman8201](https://discuss.emberjs.com/u/Panman8201)\
**Post date:** [August 17, 2015, 8:55pm UTC](https://discuss.emberjs.com/t/how-to-cancel-model-changes-without-using-emberdata/8580/4 "2015-08-17T20:55:33Z")

</div>

I also “buffer” changes by making a copy on the controller. Another option for you might be to [`model.rollbackAttributes()`](http://emberjs.com/api/data/classes/DS.Model.html#method_rollbackAttributes) before [transitioning](http://emberjs.com/api/classes/Ember.Controller.html#method_transitionToRoute) back one route/leaf. Also, assuming you are in a child of the `editor.state` route (eg: `editor.state.edit`), you don’t need to specify the model ID.

```auto
// app/controllers/editor/state/edit.js
// (snip)
actions: {
    cancel: function(){
        this.get('model').rollbackAttributes();
        this.transitionToRoute('editor.state');
    }
}
// (snip)

```
