2

Is this a knockout bug?

<h2>Debugging Variables</h2>
<div data-bind="text: ko.toJSON($root, null, 2)">
</div>

I get the following error when viewing my page in compatability mode:

Microsoft JScript runtime error: Unable to parse bindings. Message: [object Error]; Bindings value: text: ko.toJSON($root, null, 2)

Works fine when compatability mode is off.

woggles
  • 7,254
  • 12
  • 66
  • 125

1 Answers1

5

ko.toJSON uses the JSON.stringify method internally which is not implemented in IE7.

So if you want to support IE7 you need to include a JSON.stringify implementation like

Douglas Crockford's JSON2 parser (you need the json2.js file)

Community
  • 1
  • 1
nemesv
  • 135,824
  • 16
  • 405
  • 353