0
votes

I have written a simple sample of code using Knockout. I have recently started using knockout, so I think I have not understood something.

I have added the code here: http://jsfiddle.net/mEp2g/6/

I would have expected the data to appear in the table, but it does not.

var viewModel = ko.mapping.fromJS(data);
ko.applyBindings(viewModel);

When I run it on IE10, it also complains that "fromJS" is undefined. If I run it on Firefox, it gives no error, but does not show the data.

Please can anyone help.

Thanks

1

1 Answers

1
votes

Here's a working fiddle: http://jsfiddle.net/mEp2g/10/

The error was on this line:

<tbody data-bind="foreach:viewModel">

should be:

<tbody data-bind="foreach:$data">

If you do foreach:viewModel, knockout will look for a property called viewModel on you viewModel.

Also added ko.mapping to the fiddle, are you sure you are loading the ko.mapping lib correctly in IE 10 ?