knockout.js and listen to check event on checkbox

前端 未结 1 499
日久生厌
日久生厌 2020-12-15 02:15

I\'m trying to get a function to execute when a checkbox is checked or unchecked to verify all checkboxes are unchecked but it never gets executed. I assume I\'m not doing

相关标签:
1条回答
  • 2020-12-15 03:18

    You can add both a checked and click binding to an input. However, you would want to return true; from the click handler. This will allow the default action to proceed (the checkbox will be checked/unchecked).

    Here is a sample: http://jsfiddle.net/rniemeyer/cnkVA/

    An alternative technique is to push this logic into your view model and subscribe to changes to a boolean observable and execute your action like: http://jsfiddle.net/rniemeyer/cnkVA/2/

    0 讨论(0)
提交回复
热议问题