I have an Ember list and an edit form. Each time the selected list item changes, the edit form discards any changes and loads a new model.
My problem is that it is impossible to undo the changes, since the deactivation of the event does not start.
For example, a transition from url/favs/123/editto url/favs/456/editdeactivate (and exit) an event DOES NOT fire. Thus, there is no way to correctly reject any changes.
Here is part of my code, I mean:
App.Router.map(function() {
this.resource('favs', { path: '/favs' }, function() {
this.route('new');
this.route('edit', { path: ':fav_id/edit' })
});
});
[...]
App.FavsEditRoute = Ember.Route.extend({
deactivate: function() {
var model = this.get('currentModel');
if(model && model.get('isDirty')) {
model.get('transaction').rollback();
}
},
model: function(params) {
return App.Fav.find(params.fav_id);
},
});
source
share