In my view model I have a IsMale value that has the value true or false.
In my UI I wish to bind it to the following radio buttons:
<label>Male
<input type="radio" name="IsMale" value="true" data-bind="checked:IsMale"/>
</label>
<label>Female
<input type="radio" name="IsMale" value="false" data-bind="checked:IsMale"/>
</label>
The problem I think is checked
expects a string "true" / "false". So my question is, how can I get this 2-way binding w/ this UI and model?
This works for me:
http://jsfiddle.net/zrBuL/291/
After doing lot of research for older version of knockout prior to 3.0 there are possibly two best options
Create a knockout extender like
To use the extender on your model, you’d do something like the following:
source:http://www.timlabonne.com/2013/02/building-a-knockout-js-extender-for-boolean-values/