Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › Child terms unticked by default › Reply To: Child terms unticked by default
July 19, 2022 at 5:22 pm
#38497
Participant
For anyone else who runs into this issue, here’s the complete code with the refresh issue solved too.
add_action('wp_footer', 'asp_add_menu_stop_checkbox_parent_child');
function asp_add_menu_stop_checkbox_parent_child() {
?>
<script>
jQuery(document).ready(function($){
$(window).load(function(){
$('*[data-lvl]').removeAttr('data-lvl');
$(".asp_option_cat_level-1").hide();
$(".asp_option_cat_level-2").hide();
$(".asp_option_cat_level-0").click(function(){
var $next = $(this).next(), checked = $(this).find('input[type=checkbox]').prop('checked');
while ( $next.hasClass('asp_option_cat_level-1') || $next.hasClass('asp_option_cat_level-2') ) {
if ( $next.hasClass('asp_option_cat_level-1') ) {
$next.toggle();
} else {
$next.hide();
}
if ( !checked ) {
$next.find('input[type=checkbox]').prop('checked', false);
}
$next = $next.next();
}
});
$(".asp_option_cat_level-1").click(function(){
var $next = $(this).next(), checked = $(this).find('input[type=checkbox]').prop('checked');
while ( $next.hasClass('asp_option_cat_level-2') ) {
$next.toggle();
if ( !checked ) {
$next.find('input[type=checkbox]').prop('checked', false);
}
$next = $next.next();
}
});
});
});
</script>
<?php
}