I'm currently trying to break down a large section of data, which is provided by a $ajax call to a .NET webservice, that is causing a script timeout on the page when the data is being mapped to a Knockout view model. I noticed in the documentation that you should be able to bind multiple data sources to one viewmodel, like so:
var viewModel = ko.mapping.fromJS(alice, aliceMappingOptions);
ko.mapping.fromJS(bob, bobMappingOptions, viewModel);
I've tried this in my own code, as shown below, and on the first pass I bind to a new view model and then on subsequent passes I attempt to rebind to the same view model:
if(currLoadIndex == 0)
{
currViewModel = ko.mapping.fromJS(data, mappingOptions);
}
else{
ko.mapping.fromJS(data, mappingOptions, currViewModel);
}
However, this just leaves me with the last section of data I've loaded when I bind it to my template. I've tried setting a key in my 'mappingOptions' but that hasn't helped. Can anybody see anything obvious which I'm doing wrong? Any help would be much appreciated.