Forums Forums Search & Filter Pro Custom jQuery breaks search form on ajax reload

Viewing 3 posts - 1 through 3 (of 3 total)
  • Anonymous
    #226869

    I have a custom search form with the following:

    • Search
    • Sort By
    • 5x Custom taxonomy filters
    • Reset

    I am using ajax.

    To improve usability, I would ideally like to hide the custom taxonomy filters on page load and add an “Advanced” button. When clicked, this button would display the hidden filters.

    Right now I am merely trying to add <li class="toggle-advanced"><button>Advanced Search</button></li> after the Sort by filter. Per this ticket, I am adding this both on the document load and the ajaxfinish event, like so:

    
    jQuery(document).ready(function() {
      $('li.sf-field-sort_order').after('<li class="toggle-advanced"><button>Advanced Search</button></li>');
    });
    jQuery(document).on("sf:ajaxfinish", ".searchandfilter", function(){
      $('li.sf-field-sort_order').after('<li class="toggle-advanced"><button>Advanced Search</button></li>');
    });
    

    While this works on page load, when I update the filters, the reset button is duplicated.

    I have multiple methods, including wrapping the hidden filters in <li><button>Advanced Search</button><ul> ...</ul></li> with .wrapAll() however that has even wonkier results with each filter updates in that certain filter just disappear.

    Wondering if there is a simple solution for this.

    Trevor
    #226914

    I cannot advise you on this, as it is not something we support (the restructuring of the form HTML). I do know other users have done this, so I will follow up with a private reply with some other details. But, note, this is an area where we cannot offer support, and where you would be advised to contract the services of a third party code.

    Trevor
    #226916
    This reply has been marked as private.
Viewing 3 posts - 1 through 3 (of 3 total)