From e45ca02afba181fafff7e1a41c29b591f04fbf21 Mon Sep 17 00:00:00 2001 From: Matthew Dillon Date: Tue, 17 Nov 2015 16:36:08 -0700 Subject: [PATCH] Context-sensitive save-model mixin --- app/mixins/save-model.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/mixins/save-model.js b/app/mixins/save-model.js index d4459e3..2b652ff 100644 --- a/app/mixins/save-model.js +++ b/app/mixins/save-model.js @@ -23,11 +23,16 @@ export default Mixin.create({ cancel: function() { const model = this.get('model'); + const isNew = model.get('isNew'); model.get('errors').clear(); model.rollbackAttributes(); - this.transitionToRoute(this.get('fallbackRouteCancel'), model); + if (isNew) { + this.transitionToRoute(this.get('fallbackRouteCancel')); + } else { + this.transitionToRoute(this.get('fallbackRouteCancel'), model); + } }, }, });