How to update object attributes values in knockout.js at once
the way i do is one by one like the example here
self.person = {
id: ko.observable(),
name: ko.observable()
};
self.person.id("1");
self.name.id("AAAA");
what i want is something like this
self.person = {
id: ko.observable(),
name: ko.observable()
};
var temp = {
id: "1",
name : "AAAA"
}
self.person(temp)
is it possible ?
Since you tagged the knockout-mapping-plugin, here's how to do it using
ko.mapping.fromJS:For more information, check out the documentation.