Abe
Abe

Reputation: 23988

knockout loads, but does not work in IE

I'm building a client-side application with jquery and knockoutjs. It works great in FF and Chrome, but crashes in a really puzzling way in IE v8.

For debugging, I'm running this code:

$(document).ready(function(){
  //A bunch of code that works fine ...
  //...
  alert( viewModel );
  alert( ko.toJSON );
  alert( ko.toJSON(viewModel) );
  ko.applyBindings(viewModel);
  alert( "Done" );
});

IE gives me two alert boxes:

[object Object]

and

function(a){a=p.oa(a);return p.a.Y(a)}

The first one is my viewModel. I believe the second is the minimized ko.toJSON command. Why can't it run the third alert? This happens even if I set viewModel to something simple, like {};

(BTW, the ko.applybindings line doesn't work either. That's why I was debugging in the first place.)

Upvotes: 2

Views: 3951

Answers (2)

jaffa
jaffa

Reputation: 27360

I know some versions of IE don't support JSON natively and so it has to be included as a JavaScript include. Crockford's JSON2 parser: https://github.com/douglascrockford/JSON-js

But the compatibility mode of IE, if set correctly should also resolve this.

Upvotes: 0

Jeremy Roberts
Jeremy Roberts

Reputation: 821

It looks like you are running in IE 8 Compatibility Mode or in IE 7 Mode. Hit F12 and check your browser mode.

Upvotes: 1

Related Questions