2
votes

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
}
1
Yup, I tried. It says I can't for three more hours. :) - Adam Levitt

1 Answers

2
votes
function MyModelOject(data) {
    var self = this;    
    ko.mapping.fromJS(data, {}, this);

    // other functions go here
}