I've just got cracking with Knockout.js and have run into my first stumbling block, though I'm not sure whether this is a bug or whether I'm not doing something properly.
When using the css binding, on the first condition when applying multiple classes, if more than one class name contains a "-" only one is applied. This does not occur with subsequent conditions and if I remove the "-" from the class name, the class is successfully applied.
Fiddle: http://jsfiddle.net/pU9UR/
So this doesn't work:
<i class="fa" data-bind=" css: { 'fa-caret-down text-info': active() && !asc(), 'fa-caret-up text-info': active() && asc(), 'fa-unsorted text-muted': !active() }">
Whereas this does:
<i class="fa" data-bind=" css: { 'fa-caret-down textinfo': active() && !asc(),'fa-caret-up text-info': active() && asc(), 'fa-unsorted text-muted': !active() }"></i>
Is this a bug or am I missing something?
Edit:
It appears my original diagnosis was wrong, the issue occurs when I have the same class repeated for different conditions. So the below does not work (only fa-caret-down is applied):
css: { 'fa-caret-down text-danger': active() && !asc(), 'fa-caret-up text-danger': active() && asc(), 'fa-unsorted text-muted': !active() }
But this does:
css: { 'fa-caret-down text-danger': active() && !asc(), 'fa-caret-up text-info': active() && asc(), 'fa-unsorted text-muted': !active() }
New fiddle that's easier to see: http://jsfiddle.net/pU9UR/1/