I tried this one :
But it does not work :
Assuming you have this:
function viewModel() {
this.itemSelected = ko.observable(true);
}
ko.applyBindings(new viewModel());
Add a () after itemSelected to get the current value of the observable that you can use with the ternary operator:
http://jsfiddle.net/RK7Ty/
If you didn't need to assign the unselected class for the non selected state you could do this instead:
http://jsfiddle.net/RK7Ty/1/