Knockout js for attribute binding in IE8

2019-09-16 17:45发布

问题:

Can't bind for attribute in IE8

http://jsfiddle.net/k2Mq7/ - ko 2.1:

SCRIPT5022: Unable to parse bindings.
Message: SyntaxError: Expected identifier, string or number;
Bindings value: attr: { id: 'that-works', for: 'but-than-not' } 

http://jsfiddle.net/k2Mq7/3/ - ko 2.1 quoted for ('for'):

jsfiddle fails but on my local machine no any errors but this label displayed without for attribute.

Is it Knockoutjs bug or that I am doing something wrong?

回答1:

Use quotation marks for attributes names like this:

<label data-bind="attr: { 'for': vmProperty }"></label>