Support Forums

The forums are closed and will be removed when we launch our new site.

Looking for support? You can access the support system via your account.

Forums Forums Search & Filter Pro Reset Filters on search results page

Viewing 10 posts - 1 through 10 (of 11 total)
  • Paule Jorrot
    #182832

    Hello

    I’m using search and filters Pro version.
    On my search result page (post type archive), after a research using checkbox selection, my searc form is still filtered and selected.

    can you pease let me know how to reset the searchform ?

    thanks

    Trevor Moderator
    #182849

    Do you mean that you make a search and the results show, but the form still shows the search selections, and you would like them to be reset but for the results to be correct for the last search, OR do you need a way to reset the form (which will reset the results to ALL)?

    Paule Jorrot
    #182851

    When a make a search, I check 2 or 3 categories for example. I don’t want to use Ajax, so page is changed to my result page, and my selection still shows the search selection, which I don’t want.
    I want to have all my search options available so I can run a new search.
    let me know if you understand, thanks

    Trevor Moderator
    #182859

    That is what I had thought. This is not an option in our plugin.

    Our plugin detects the filter selections and sets itself to match. You would have to write a custom javascript that runs on document load to clear the selections. Of course, you cannot have Auto Submit, as if you did, as soon as the form showed no selections from running the script, it would change the results. Thus you must also use a Submit button.

    Paule Jorrot
    #182861

    I’m not using auto submit of course, and I use a submit button.

    where are the API commands on the documentation ?
    what’s the code to clear the selections ?

    thanks

    Trevor Moderator
    #182866

    Our filters and actions are detailed here:

    https://searchandfilter.com/documentation/action-filter-reference/

    But I do not think you need them. I do not have a example of a script to clear the selections. You would need to code that yourself.

    Paule Jorrot
    #182868
    This reply has been marked as private.
    Trevor Moderator
    #182911
    This reply has been marked as private.
    Ross Moderator
    #182966

    Hi Paule

    We don’t actually have a javascript api as such, which is why there is no documentation on it (coming in v3).

    So to get this picture clear, you perform a search, which takes you to a search results page, with a search form on it, however you want to this form to be blank / unset.

    There is no simple way to do this as its going against how the plugin is supposed to work but I’ll describe possible approaches:

    1) as Trevor mentioned, on page load you can unset all the fields. you would beed to loop through all inputs and unset / clear the various fields. For checkboxes this would be setting .prop('checked', false). However, I still think there could be some issues surrounding this if you have auto cont enabled.

    2) we do provide an api to manipulate fields/values, but this is PHP based – https://searchandfilter.com/documentation/action-filter-reference/#filter-input-object

    Take a look at the full fledged example, what you’ll want to do is empty the ‘defaults’ array under certain conditions (ie, check current page before applying your changes) so that nothing is set.

    The only thing is, our search form is intrinsically tied to the current search query in order to provide auto count / dynamic fields, so there may still be some hiccups with this approach for what you want to do.

    Im away until next week due to family matters so can’t test this theory myself.

    As a final idea, we do have a reset field, which has the option to reset the form but not the query/results.

    Its possible this piece of JS code might work for you, Ill have to dig it out on my return when Im back at my dev PC.

    Thanks

    Ross Moderator
    #183441

    Hi Paule

    I had a quick play and figured we can access the JS reset function:

    var searchForm = {};
    $('body').append("<button id='sfreset'>RESET</button>");
    
    $('#sfreset').click(function(){
    	resetForm();
    });
    
    function resetForm(){
    	searchForm.resetForm(false);
    }
    
    $(document).on("sf:init", ".searchandfilter", function(e, data){
    	searchForm = data.object;
    });

    This just appends a basic button demonstrating the functionality.

    The only issue you’ll have is, if you are using “auto count”, although the form is cleared, the form is not fully reset, an the filters still have a relationship with the results (so the showing / hiding of options based on selections won’t update).

    I think this is not what you were looking for, I’ll take this on board and see if we can add support for this in v3.

    Thanks

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

The topic ‘Reset Filters on search results page’ is closed to new replies.