Context-sensitive save-model mixin

This commit is contained in:
Matthew Dillon 2015-11-17 16:36:08 -07:00
parent 2bbb29d785
commit e45ca02afb

View file

@ -23,11 +23,16 @@ export default Mixin.create({
cancel: function() { cancel: function() {
const model = this.get('model'); const model = this.get('model');
const isNew = model.get('isNew');
model.get('errors').clear(); model.get('errors').clear();
model.rollbackAttributes(); model.rollbackAttributes();
this.transitionToRoute(this.get('fallbackRouteCancel'), model); if (isNew) {
this.transitionToRoute(this.get('fallbackRouteCancel'));
} else {
this.transitionToRoute(this.get('fallbackRouteCancel'), model);
}
}, },
}, },
}); });