I want to switch an object in viewModel with a different one with the same type (e.g. Person). If I do this:
var personViewModel = function (person) { var self = this; self.id = person.id; self.firstName = ko.observable(person.firstName); self.lastName = ko.observable(person.lastName); self.addresses = ko.observableArray(contact.addresses); self.removeAddress = function (address) { self.addresses.remove(address); } }
and link it to:
ko.applyBindings(new personViewModel(person), $("#person")[0]);
it works great the first time, but if I link it to another object a second time, the first binding will not go away.
How can I easily switch an object of an object into my view mode?
G meile
source share