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

Reply To: Change term order of Taxonomy Frontend outpus

Home Forums Product Support Forums Ajax Search Pro for WordPress Support Change term order of Taxonomy Frontend outpus Reply To: Change term order of Taxonomy Frontend outpus

#35761
willfaulds59willfaulds59
Participant

Thanks Ernest,

One last addon before it closes…

Some reasonably robust (perhaps you can suggest a better solution than using the ‘click’ event) and commented javascript for making filters act like toggles (in this case ONLY one can be one at a time, but both can be off, so NOT a true toggle).

example of ASP toggles using javascript

jQuery(window).ready(function($) {
	function linkASPFrontendFilterEvent( $master, $slave ){
		$master.on('click', function () {//must be ASP js that prevents 'change' working (even if override the input being hidden)
			if( jQuery(this).find('input[type=checkbox]').is(':checked') ) {//must be ASP js that prevents .checked working
				$slave.find('input[type=checkbox]').prop( "checked", false );
			}
		});
	}

	function linkASPFrontendFilter( term1, term2 ){
		if( jQuery( '.'+term1) !== null && jQuery( '.'+term2) !== null ){
			var $elem1 = jQuery( '.asp_option.'+term1 );
			var $elem2 = jQuery( '.asp_option.'+term2 );
			linkASPFrontendFilterEvent( $elem1, $elem2 );
			linkASPFrontendFilterEvent( $elem2, $elem1 );
		};
	};

	//array toggle classes to be linked (Requires a theme override e.g. asp-tax-checkboxes.php with "str_replace(' ', '-', strtolower(strip_tags($term->label))); ?> ")
	const ao_asp_toggles = [
		['alcoholic','non-alcoholic'],
		['sparkling','still'],
	];
	//loop through the classes
	for (i = 0; i < ao_asp_toggles.length; ++i) {
		linkASPFrontendFilter( ao_asp_toggles[i][0], ao_asp_toggles[i][1] );
	};
});
  • This reply was modified 4 years, 6 months ago by willfaulds59willfaulds59.
  • This reply was modified 4 years, 6 months ago by willfaulds59willfaulds59.
  • This reply was modified 4 years, 6 months ago by willfaulds59willfaulds59.
  • This reply was modified 4 years, 6 months ago by willfaulds59willfaulds59.