Knockout CSS styling, through a function as well as a binding
I know that you can use knockout to set the class as per a function return
like so;
<span data-bind="css: styling()"></span>
You can also set them inline with a true/false value.
<span data-bind="css: {className: $parent.active() == $data}"></span>
Is there a way to do both in the one binding? My example is that I want to
return a custom class depending on the type of the item displayed by the
span element (there will be many of these) but I also want them to be
highlighted if they are selected.
It seems that you cannot use functions on the right hand side of the
object, and having two cause the second to overwrite the first.
Any ideas?
No comments:
Post a Comment