mercredi 30 octobre 2019

Change value attribute of checkbox base on checked value with knockout JS

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.




Aucun commentaire:

Enregistrer un commentaire