The interesting part is that if you remove the checked model.on, it works again. The theory is that NoOp gets triggered (synchronously), re-renders the DOM, overwriting the newly checked value, before the Toggle event handler is triggered. Because Toggle uses the checked value for the boolean it sends with the message, it sends the wrong boolean, since the checked value was flipped back by the NoOp render.
A possible work around just to ignored the checked value from onCheck and just toggle your model directly.
If you have the following code:
the checkbox will not toggle.
The interesting part is that if you remove the
checked model.on
, it works again. The theory is thatNoOp
gets triggered (synchronously), re-renders the DOM, overwriting the newlychecked
value, before theToggle
event handler is triggered. BecauseToggle
uses thechecked
value for the boolean it sends with the message, it sends the wrong boolean, since thechecked
value was flipped back by theNoOp
render.A possible work around just to ignored the
checked
value fromonCheck
and just toggle your model directly.See ellie example.