I have a simple ember-data model (rev 12 -master as of 04/21/2013)
App.Foo = DS.Model.extend({
name: DS.attr('string')
}).reopenClass({
add: function(json) {
//call create record but don't commit it
var store = DS.get('defaultStore');
store.createRecord(App.Foo, json);
}
});
At some point in my application I need to remove an item from the store so I tried the usual
var foo = store.find(App.Foo, 1);
foo.deleteRecord();
But because the record is not completely loaded (server side) I get the error
Uncaught Error: Attempted to handle event
deleteRecord
on while in state rootState.loading. Called with undefined
If I plan to use ember-data in this way how can I "fake" the commit or mark the record as loaded manually?
store.find(App.Foo, 1).then(function(data){data.deleteRecord();});
– mehulkardeleteRecord
all over the place for records that weren't commited, btw. But I usually have a handle on the instance of that record without having to callfind
– mehulkardeleteRecord
should be working too as Mehul is saying. It works for me. – MyslikContactsAddRoute
– MilkyWayJoe