I try simply demonstrate radio button binding from knockout.js tutorials but it does not work as it is. For example comments says that msg value should be checked but it is not.
Documentation link is here http://knockoutjs.com/documentation/checked-binding.html
<p>Send me spam: <input type="checkbox" data-bind="checked: wantsSpam" /></p>
<div data-bind="visible: wantsSpam">
Preferred flavor of spam:
<div><input type="radio" name="flavorGroup" value="cherry" data-bind="checked: spamFlavor" /> Cherry</div>
<div><input type="radio" name="flavorGroup" value="almond" data-bind="checked: spamFlavor" /> Almond</div>
<div><input type="radio" name="flavorGroup" value="msg" data-bind="checked: spamFlavor" /> Monosodium Glutamate</div>
</div>
var viewModel = {
wantsSpam: ko.observable(true),
spamFlavor: ko.observable("almond") // Initially selects only the Almond radio button
};
// ... then later ...
viewModel.spamFlavor("msg"); // Now only Monosodium Glutamate is checked
Here is link http://jsfiddle.net/HhXGH/55/
You are missing this line at the bottom:
ko.applyBindings(viewModel);
FYI: If you don’t know what ko.applyBindings is, and how it interacts with Knockout bindings, please read the Activating Knockout section here: http://knockoutjs.com/documentation/observables.html
Edit: updated fiddle
http://jsfiddle.net/jearles/HhXGH/56/