Reply To: trigger the search on passing in a value

Home Forums Product Support Forums Ajax Search Pro for WordPress Support trigger the search on passing in a value Reply To: trigger the search on passing in a value

#12068

Ernest Marcinko
Keymaster

Hi,

If I'm not mistaken, you are using this code currently:

jQuery( document ).ready(function($) {    
	$('.cat-head').on('click', function(e){
	      e.preventDefault();
	      var srch = $(this).find('.cat-head-element').html();
	      $('.orig').val(srch); 
	  });
});

It's almost perfect, but the best way of triggering the search, is to use the search javascript API, instead of changing the node values. This should be the best possible solution:

jQuery( document ).ready(function($) {    
	$('.cat-head').on('click', function(e){
	      e.preventDefault();
	      var srch = $(this).find('.cat-head-element').html();
	      ASP.api(0, 'searchFor', srch);
	  });
});

To learn more about API functions, you can check this documentation article.

Best,
Ernest Marcinko

If you like my products, don't forget to rate them on codecanyon :)