This website uses cookies to personalize your experience. By using this website you agree to our cookie policy.

Reply To: Child terms unticked by default

#38487
Ernest MarcinkoErnest Marcinko
Keymaster

You are welcome. That should not be too difficult, try this instead of the previous version:

jQuery(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();
		}
	});  
});