Using the last version of ember-js and ember-data, I got an issue when deleting a record.
My route :
App.ListContactsRoute = Em.Route.extend({
model: function() {
App.Contact.find();
},
setupController: function(controller, model) {
controller.set('contacts', model);
}
});
App.EditContactRoute = Em.Route.extend({
setupController: function(controller, model) {
this.transaction = controller.get('store').transaction();
this.transaction.add(model);
controller.set('content', model);
controller.set('organizations', App.Organization.find());
},
events: {
delete: function(contact) {
contact.deleteRecord();
this.transaction.commit();
this.transaction = null;
this.transitionTo("listContacts");
},
save: function(contact) {
this.transaction.commit();
this.transaction = null;
this.transitionTo("editContact", contact);
}
}
});
When deleting a contact, I'm going back to the ListContactsRoute, so a call is made to the API wich returns me a list of contacts. At this point, the deleted contact hasn't been deleted on the server yet.
In result, the deleted contact is still present on my contacts list template. Here's the error :
"Uncaught Error: Attempted to handle event `loadedData` on <App.Contact:ember469:null> while in state rootState.deleted.inFlight. Called with undefined"
Am I doing something wrong or is there a way to fix this ?