You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Select/Deselect all does not trigger change JS DOM events #1504
I'm trying to conditionally do things dependent on the value of other fields, and have a change event which works great. But it does not work for multicheck fields. This is because cmb.toggleCheckBoxes uses .prop to clear/set the checkboxes but this does not fire the change event, it must be triggered manually which it isn't.
Steps to reproduce (I have confirmed I can reproduce this issue on the develop branch):
Set up a multicheckbox
attach change event listeners that do something to the checkbox input elements
// If the button has already been clicked once...if($this.data('checked')){// clear the checkboxes and remove the flag$multicheck.prop('checked',false).trigger('change');$this.data('checked',false);}// Otherwise mark the checkboxes and add a flagelse{$multicheck.prop('checked',true).trigger('change');$this.data('checked',true);}
or even for a 1 line change at the end:
// If the button has already been clicked once...if($this.data('checked')){// clear the checkboxes and remove the flag$multicheck.prop('checked',false);$this.data('checked',false);}// Otherwise mark the checkboxes and add a flagelse{$multicheck.prop('checked',true);$this.data('checked',true);}$multicheck.trigger('change');
Activity
tomjn commentedon Dec 12, 2023
@jtsternberg thanks for the fast turn around! ❤️
jtsternberg commentedon Dec 12, 2023
trigger JS DOM events when toggling checkboxes. Fixes CMB2#1504
Merge remote-tracking branch 'upstream/master' into develop