Reputation: 24498
I have some very basic binding .. working. Now I am trying to delete a row. It is not working.
I am not passing the correct
var ClientModel = function () {
this.clients = ko.observableArray(data); // Load json data
self.del = function(elem) {
if (confirm('Delete: ' + elem.Name)) {
this.client.remove(elem);
};
}
}
I am not sure why the remove is not working.
Upvotes: 2
Views: 1647
Reputation: 1551
For one thing - change this.client.remove(elem); to: self.clients.remove(elem);
You specified "this" instead of "self", and "client" instead of "clients"
Upvotes: 0
Reputation: 23990
The functions for selection and deletion are in the parent view model, so you should call them with $parent.select
and $parent.del
.
Also this line had some mistakes:
self.clients.remove(elem);
Here is the fixed jsfiddle.
Upvotes: 4