Hide Search Results on Page Load

Forums › Forums › Search & Filter Pro › Hide Search Results on Page Load

Viewing 4 posts – 1 through 4 (of 4 total)
  • Anonymous
    #17778

    Hey Ross,

    I’m wanting to hide the results on initial page load, but don’t see a setting for that. I’m attempting to do it with AJAX. When I set the ‘.search-filter-results’ to display: none, they hide. However, when target the first result (it’s a placeholder – “All States”) as a check to see if it’s selected or not, I can’t seem to get the results show if it’s not. Does my jQuery look sound?

    
    jQuery(document).bind('ready ajaxComplete', function() {
    $j('.search-filter-results').css('display','none');
    if (!$j('#search-filter-form-205 .postform option[value="0"]')) {
    $j('#search-filter-form-205 .search-filter-results').css('display','block');
    }
    });
    

    URL is http://kevinobrienstudio.dreamhosters.com/two-filters/

    Ross Moderator
    #17780

    Check the first question in the FAQs –

    http://www.designsandcode.com/wordpress-plugins/search-filter-pro/faqs/

    This has the code to do what you need..

    I would start by hiding the results using CSS

    .search-filter-results
    {
        display:none;
    }

    The use the ajax finish hook from the FAQs:

    $(".searchandfilter").on("sf:ajaxfinish",function(e, x){
       //show my results here
        console.log(e);
        console.log(x);
    });

    Thanks

    Anonymous
    #17782

    When you say “//show my results here,” do you mean I should include a call to display results as I was in the code sample I sent?

    
    $j('#search-filter-form-205 .search-filter-results').css('display','block');
    
    Ross Moderator
    #18013

    Hey Dan

    I’m not sure what $j is, possibly an alias to jQuery?

    Anyway, yeah you would need to add the javascript for showing your results again, something like:

    $('.search-filter-results').show();

    Thanks

Viewing 4 posts – 1 through 4 (of 4 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.