var user = Ext.create('User', {
extend : 'Ext.data.Model',
fields : ['id', 'name', 'email'],
proxy : {
type : 'rest',
url : '/users'
}
});
user.set('id', '12345');
user.erase();
In the preceding function call, will not be any XHR request with 'DELETE' method as we expect, if you are using ExtJS-5.1.0. In ExtJS 4, if there is any change in the ID property, it calls a function(changeId) that does house keeping of a model hence, model's phantom becomes false whereas in ExtJS5, user.set('id','12345') will not change user's phantom to false(When we create model using Ext.create, default phantom value will be true). Since it is a phantom record(new record), it will not call any 'DELETE' request.
Here is a simple hack to handle this problem. We hope there will be a fix in their future releases.
user.set('id','12345');
user.commit(); // user.phantom becomes false
user.erase();
oruser.set('id','12345');
user.phantom = false; //Make phantom as false manually
user.erase();
No comments:
Post a Comment