Forums › Forums › Search & Filter Pro › Hide Search Results on Page Load
Tagged: hide results, jquery
- This topic has 3 replies, 2 voices, and was last updated 9 years, 6 months ago by Ross.
-
Anonymous(Private) May 18, 2015 at 3:57 pm #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(Private) May 18, 2015 at 4:11 pm #17780Check 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
Ross Moderator(Private) May 21, 2015 at 1:00 pm #18013Hey 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
-
AuthorPosts