When i want deal with radio button in knockout 2.0 I used the below code but now i upgrade to knockout 3.1 and this below code throw exception say that update is not a function.
ko.bindingHandlers.radioOnOffBoolean =
{
init: function (element, valueAccessor, allBindingsAccessor) {
var value = valueAccessor();
var newValueAccessor = function () {
return ko.dependentObservable({
read: value,
write: function (newValue) {
value(newValue === "On");
}
});
};
ko.bindingHandlers.checked.init(element, newValueAccessor, allBindingsAccessor);
},
update: function (element, valueAccessor) {
var value = ko.utils.unwrapObservable(valueAccessor());
var newValueAccessor = function () {
return value ? "On" : "Off";
};
ko.bindingHandlers.checked.update(element, newValueAccessor);
}
};
Knockout v3 now checks for strict equality when comparing model values and element values for the checked binding.