Reset Filter when select another

Forums › Forums › Search & Filter Pro › Reset Filter when select another

Tagged: , ,

Viewing 7 posts – 1 through 7 (of 7 total)
  • Anonymous
    #152315

    Hey,

    I have set up a filter with category and tag forms. The user should only select a Category OR a Tag. In the settings I selected field relationships = OR. But when the user has a category filter set and then set a tag filter, the results shows the posts with the tags in this category. Is it possible to reset the filter, when the user select a category or tag?

    Marvin

    Trevor
    #152325

    This is not a feature of our plugin, but is possible (with third party coding) via the use of javascript that checks the onchange of both fields. When one changes, it return the other to default. I do not have a code snippet for you, but you might well find something you can use on stackexchange.

    Anonymous
    #152404

    Thanks for your answer. I already tried to remove the url parameter with javascript. But it don’t work. Does the plugin has a javascript event to reset the filter?

    Anonymous
    #152406

    I mean function not event.

    Trevor
    #152410

    You could add the reset button/link to the form (even if you then hide it) and use this to ‘click’ it:

    document.getElementsByClassName("search-filter-reset")[0].click();
    
    Anonymous
    #152422

    Thanks for your help! I just solved it with this code:

    $('.sf-input-radio[name="_sft_post_tag[]"]').click(function() {
        $('.sf-input-radio[name="_sft_category[]"]').removeAttr('checked');
        $('.sf-input-text').removeAttr('value');
      });
    
      $('.sf-input-radio[name="_sft_category[]"]').click(function() {
        $('.sf-input-radio[name="_sft_post_tag[]"]').removeAttr('checked');
        $('.sf-input-text').removeAttr('value');
      });
    
      $('.sf-input-text').change(function() {
        $('.sf-input-radio[name="_sft_category[]"]').removeAttr('checked');
        $('.sf-input-radio[name="_sft_post_tag[]"]').removeAttr('checked');
      });
    Trevor
    #152424

    Thanks for sharing. I will close this thread for now.

Viewing 7 posts – 1 through 7 (of 7 total)
Search & Filter Support
Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.

We also use cookies to store items in your cart as well as allowing your to login on the site.

You can adjust all of your cookie settings by navigating the tabs on the left hand side.

By continuing to use this site, you also agree to our Privacy Policy.