I am using ember-model here. I am trying to delete record from array which is one of the node of fixture.
This (cart_items
) array has hasMany
relation with model.
I have posted my complete code here.
Here, i am trying to delete row from table using following code :
deleteproduct: function(product){
if (window.confirm("Are you sure you want to delete this record?")) {
this.get('model').map(function(application) {
application.get('cart_items').deleteRecord(product);
});
}
}
But it is throwing an exception : Uncaught TypeError: Object [object Object] has no method 'deleteRecord'
Same thing i tried using this. Here, i am not getting any exception but record is also not getting delete.
deleteproduct: function(product){
if (window.confirm("Are you sure you want to delete this record?")) {
this.get('model').map(function(application) {
application.get('cart_items').map(function(cartitem) {
console.log("+++++++++++++++++++++++");
console.log(JSON.stringify(cartitem));
console.log("***********************");
console.log(JSON.stringify(product));
product.deleteRecord();
});
});
}
}
I am not getting what is happening here?
I think there is some context issue which i am not able to find out. Can anyone help me to make this jsfiddle work?
You should use
removeObject
instead ofdeleteRecord
.edit: I've updated your jsfiddle, The
removeObject
method is oncart_items
not onproduct
.