Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Knockout JS 2.0 Binding Parse Error in IE

Can someone tell me what's wrong with this http://jsfiddle.net/Yp8Bz/? It works fine in Chrome/Firefox, but in IE 8 I get the following error:

Message: Unable to parse bindings. Message: SyntaxError: Expected identifier, string or number; Bindings value: click: blah, attr: {class: 'Hi'} Line: 38 Char: 359 Code: 0 URI: http://cdnjs.cloudflare.com/ajax/libs/knockout/2.0.0/knockout-min.js 
like image 732
davertron Avatar asked Jan 31 '12 20:01

davertron


People also ask

What is data bind in knockout JS?

Knockout's declarative binding system provides a concise and powerful way to link data to the UI. It's generally easy and obvious to bind to simple data properties or to use a single binding.

What is text binding?

Text binding causes the associated DOM element to display the text value of the parameter. This is used in text-level DOM elements such as <span> or <em>. The text binding accepts any data type and parses it into String before rendering it.

What is two-way data binding in knockout JS?

KO is able to create a two-way binding if you use value to link a form element to an Observable property, so that the changes between them are exchanged among them. If you refer a simple property on ViewModel, KO will set the form element's initial state to property value.


1 Answers

Put class in quotes. I ran into the same issue when using a reserved word.

attr: {'class': 'Hi'} 
like image 70
Daniel A. White Avatar answered Oct 13 '22 22:10

Daniel A. White