lundi 26 février 2018

Knockout.js: disable other checkboxes when one checkbox is selected

I'm new with Knockout and I'm struggling with the following issue.

I have made some product divs that are clickable (with a hidden checkbox). If someone clicks on a div, a hidden checkbox is selected and the style changes.

Now I want to add dependencies, as some products cannot be ordered simultaneously. I want to do this based on the checkbox value (true/false). So let's say, if product 1 is selected, product 2 and 3 should be disabled with an additional class "disabledDiv". However, this event change binder does not do the trick for me. I doesn't even fire an alert.

self.valueCheckboxChanged = function() {
  alert('value has changed')
}

Can someone please help me, I'm at a loss. I made a simplified JSFiddle (https://jsfiddle.net/Seabiscuito/f1qnr8a2/) to illustrate the problem.




Aucun commentaire:

Enregistrer un commentaire