I am writing a plugin using jQuery and knockout. I have two radio buttons. I am using knockout data-bind to check and uncheck the radio button. The problem is that when I am trying to uncheck the radio button on click of another button using jQuery, it is not updating bind observable property .
<input type="radio" data-bind="checked: selectedVal" name="1" value="fixedPrice"/> Fixed Price
<input class="hn" type="radio" data-bind="checked: selectedVal" name="1" value="allowBiding"/> Allow Biding
<pre data-bind="text:ko.toJSON($data,null,2)"></pre>
<input type="button" id="button" value="Click Me" />
var onClick = function() {
$('.hn').prop('checked', true);
};
$('#button').click(onClick);
var ViewModel = function () {
var self = this;
self.selectedVal = ko.observable("fixedPrice");
self.selectedVal.subscribe(function (val) {
console.log(val)
});
};
ko.applyBindings(new ViewModel());
Please find this jsfiddle below with more details.