I have a controller that lists all the units-of-measure in the system. When a user chooses a specific record in the Uom
model I want to be able to delete it. I'm using Ember-Data beta-2. Here's what I have so far:
App.UomsController = Ember.ArrayController.extend({
actions: {
deleteRecord: function(id) {
console.log("deleting: " + id);
var promisedDelete = this.store.find('uom',id).then(function(uom){
uom.deleteRecord();
});
}
}
});
The action deleteRecord
is called passing in a valid ID and a promise is returned. Using the then()
functionality of the promise I then call Ember's deleteRecord()
when the promise has been fulfilled and it appears to work locally. I say that because this record immediately disappears from the screen and the Ember Debugger. Unfortunately the delete has not been persisted to the backend and a reload of hte page immediately brings back the locally "deleted" record.
My questions are:
- Is this a reasonable way to execute a local delete?
- How do I persist a delete to the backend?