Forums Forums Search & Filter Pro Auto Submit when input value changes

  • This topic has 10 replies, 3 voices, and was last updated 4 years ago by Ross.
Viewing 10 posts - 1 through 10 (of 11 total)
  • Anonymous
    #263445

    Hi,

    I’m wanting to have my S&F form submit when the input value changes via javascript.

    For example:

    
    $("#button").on("click", function(){
       $(".sf-input-text").val("Desired Search Term");
    });
    

    When the value is changed via javascript, nothing happens. The input has to be manually typed. Is there a way to trigger the submit event after the value is changed? I tried using .trigger(“input) with no luck.

    Thanks

    Trevor
    #263470

    Add this to the script:

    $('.searchandfilter').submit()

    Anonymous
    #263503

    $(‘.searchandfilter’).submit() does successfully submit the form. However, the search term does not carry over to the search template page. It simply returns results as if the search term was empty.

    Trevor
    #263509

    Are you trying to send a search term from a theme search box (such as one might find in a header/nav bar) to our search form on a results page?

    Anonymous
    #263519

    No, I’m using an S&F widget. I’ve put together an example site here:http://holmestuned-001-site3.itempurl.com/

    Click on the ‘Custom Search Term’ button to fill the S&F search bar and submit the form. Notice that the search term is not being saved.

    You can manually type into the search box and everything works fine.

    Trevor
    #263521

    The original code may need to be:

    $("#button").on("click", function(){
       $(".sf-input-text").val("Desired Search Term").change();
    });

    I am not sure if you would then need to submit, so try it without at first.

    Anonymous
    #263523

    Unfortunately, that’s not working. I tried both ways as you mentioned. Adding $(‘.searchandfilter’).submit() does the same with no search term being carried over to the results page.

    Trevor
    #263526

    I have referred this thread to our developer, Ross, for his input.

    Ross Moderator
    #263732

    Hi Nathan

    That’s odd indeed… I tested on our demo site, and it works fine.

    So I thought, maybe your theme is doing something different with the input field / js events… so I tried to “blur” the field before submitting, and it seems to work?

    jQuery( '#search-filter-form-15 .sf-field-search input[type="text"]' ).val("test");
    jQuery( '#search-filter-form-15 .sf-field-search input[type="text"]' ).blur();
    jQuery( '#search-filter-form-15' ).submit();

    Thanks

    Anonymous
    #263863

    Hi Ross,

    I added your code to my test site. The results are the same, it’s submitting the form but the search term is not being stored.
    http://holmestuned-001-site3.itempurl.com/

Viewing 10 posts - 1 through 10 (of 11 total)