Knockout.js Script1028 – Expected identifier string or number (in IE8)

Issue:

Have been developing an app which uses knockout js. All seemed to work fine until I tried to test on IE8. I kept on getting an error “Script1028 – Expected identifier string or number”.

Possible Causes and Solutions:

  1. When binding using knockout js, make sure that there are no trailing commas at the end of the data-bind such as: data-bind=” text: ‘click me’, attr:{href: ‘www.rochcass.com’},
  2. When binding a javascript reserved word, such as “this, if, class”, make sure to stringify that specific reserved word. For a full list of reserved word, click here

Just an FYI, my solution was number 2, I had a data-bind=” class: ‘sampleClass’ “ and since class is a javascript reserved word this had to be written as data-bind=” ‘class’: ‘sampleClass’ “.

Hope this helped 🙂

 


It’s Not a Typo! Get $1.49 .COM Domains at GoDaddy!