Since you're sending the data to this webservice, what you should be doing is implementing the toJSON()
function on your object and remove the property there. Then send the result of calling ko.toJSON()
on the model. That way, your model still contains the property but what you send has the properties removed.
var Person = function(id, name, country) {
var self = this;
self.id = ko.observable(id);
self.name = ko.observable(name);
self.country = ko.observable(country);
self.toJSON = function () {
var data = ko.toJS(self); // get the values of this model
// delete the property from the data
delete data.country;
return data;
};
};
var person = new Person(1, 'foo', 'bar');
var data = ko.toJSON(person); // {"id":1,"name":"foo"}