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

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 MarcinkoErnest Marcinko
Keymaster

Hi,

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

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

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:

[html]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);
});
});[/html]

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