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

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

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #12065
    petermacpetermac
    Participant

    Hi .. you helped me a while ago with changing the code in my functions file to return the sub-categories on a category search. That is working great. What I want to do now is in jQuery or javascript trigger the keydown keyup event so that the search triggers when I pass it the category value. You can see how this works now on my development home page when you click on the “housing” category the term “housing” is passed to the search tool, but we have to press enter to make it perform the search.

    I have granted you FTP access above as well if that is needed.

    #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.

    #12076
    petermacpetermac
    Participant

    AWESOME ! That works !
    Thanks so much !!

    #12078
    Ernest MarcinkoErnest Marcinko
    Keymaster

    You cannot access this content.

Viewing 4 posts - 1 through 4 (of 4 total)
  • The topic ‘trigger the search on passing in a value’ is closed to new replies.