Reputation: 10476
I want to map a very large object with many fields into a javascript object using this technique:
var viewModel = ko.mapping.fromJS(data);
However, I also want to be able to add other properties/functions to the viewModel. How would that be done?
EDIT -- here is the answer:
The answer to this question is the following:
function MyModelOject(data) {
var self = this;
ko.mapping.fromJS(data, {}, this);
// other functions go here
}
Upvotes: 2
Views: 146
Reputation: 10476
function MyModelOject(data) {
var self = this;
ko.mapping.fromJS(data, {}, this);
// other functions go here
}
Upvotes: 2