I'm trying to a checkbox and send the value YES or NO in my submitted form, base in if is checked or no but the value is not updated here is my code:
self.checkbox = ko.observable("No");
self.is_checked = ko.computed({
read: function (data) {
return false;
},
write: function (data, event) { self.is_checked() ? self.checkbox('Yes'): self.checkbox('No');}
});
data-bind="checked: is_checked, checkedValue:checkbox"
any clues or links to read, please.
Your computed
readfunction should returntrueorfalseso the UI is updated by thecheckedbinding, and you can removecheckedValueentirely (checkedValue usually only makes sense to use with radio elements).