Sunday, 29 September 2013

jquery mobile and knockout checkbox not updating with viewmodel

jquery mobile and knockout checkbox not updating with viewmodel

I have two jQuery Mobile checkboxes bound to the same knockout viewmodel
member. I expect clicking on one check box to update the viewmodel and in
turn update the other checkbox to be checked too. see example here
The HTML
<span data-bind="text: chk"></span>
<input id="checkbox1" name="" data-bind="checked: chk" type="checkbox">
<label for="checkbox1">A</label>
<input id="checkbox2" name="" data-bind="checked: chk" type="checkbox">
<label for="checkbox2">B</label>
The Javascript
function ViewModel(){
var self = this;
self.chk = ko.observable(false);
}
ko.applyBindings(new ViewModel());
I can see the model is updating, with a text field showing its value. But
the checkbox is not

No comments:

Post a Comment