3

I have a class a class named Foo and Foo contains Model. I am doing a ko.applyBinding on Foo. The Foo class has a function which retrieves JSON from server and then I do:

 self.Model = ko.mapping.fromJS(result);

where self is instance of Foo and result is JSON. This works 1st time. However, when 2nd item I retrieve data from server it just doesn't work.

But if the above line to:

 self.Model = ko.mapping.fromJS(result, {}, self);

it works.

Can anybody tell me why is the 1st one not working and 2nd one works?

Tim Tom
  • 2,152
  • 6
  • 27
  • 39

1 Answers1

7

Your second line should be:

ko.mapping.fromJS(result, {}, self.Model);
Keith Nicholas
  • 43,549
  • 15
  • 93
  • 156