How to conditionally render a css class with knockoutjs
knockout.js
Solution
Something like
<div data-bind="css: {'control-group': true, error: (!$data.DealCodeIsValid)}">
Check here for more info
Problem
I have some html like the following: ``` <div class="control-group"> <input type="text" data-bind="value: $data.DealCode" name="DealCode" class="input-mini" /> </div> ``` However, `ifnot: $data.DealCodeIsValid`, I need to render the following: ``` <div class="control-group error"> <input type="text" data-bind="value: $data.DealCode" name="DealCode" class="input-mini" /> </div> ``` Note the additional class "error" in the div. Is there a way to do that with knockoutjs?