Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Without setTimeout, adding children seems to override
- // adding the current checkbox instead of running in addition to it
- setTimeout(() => {
- let checkboxes = cb.closest( ".editor-post-taxonomies__hierarchical-terms-choice" ).querySelectorAll("input[type='checkbox']");
- if ( checkboxes.length )
- {
- checkboxes = Array.from( checkboxes );
- checkboxes.splice( cb.id, 1 ); // Remove current checkbox from the array.
- // Click the child checkboxes if they do not match the checked state of the current checkbox.
- checkboxes.map( checkbox => {
- if ( (cb.checked && !checkbox.checked) || (!cb.checked && checkbox.checked) ) {
- checkbox.click();
- }
- } );
- }
- // jQuery(cb)
- // .closest('.components-base-control')
- // .siblings()
- // .find(cb.checked ? ':checkbox:not(:checked)' : ':checkbox:checked')
- // .trigger('click');
- }, 10);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement