Forums › Forums › Search & Filter Pro › Scroll to filter on load?
- This topic has 7 replies, 2 voices, and was last updated 4 years, 10 months ago by
Trevor.
-
Anonymous(Private) June 18, 2020 at 6:15 pm #249381
Hello, thanks for the great plugin.
Is it possible to scroll the window to the filter on load (in the case that you’re accessing the page with filter parameters applied to the permalink)?
If there isn’t a setting for this is there script that I can add to my theme?
Anonymous(Private) June 19, 2020 at 4:39 pm #249474Hey Trevor, thanks for the response. Yup—I have that all set up to scroll to the search form on ‘all’.
My question is, if I go to the page using the ‘bookmarkable permalink’, is it possible to scroll to the search form as if I was using an anchor link?
Matter of fact, I don’t even mind if it doesn’t scroll. Is there a setting to make the ‘bookmarkable permalink’ show the search form (or any other #) at the top of the window?
Thanks again!
Trevor(Private) June 19, 2020 at 4:45 pm #249481I guess all you would need to do is make one of the containing elements for the form has an ID and simply use that, maybe something like this:
mysite.com/searchpage/#myid?_sf_s=hello
Maybe? I am not sure if that would work though. You might have to set the page up with some form of JavaScript that scrolls the page down to the form.
Trevor(Private) June 19, 2020 at 6:39 pm #249497I am not aware of any code snippets, but a search of Google gives me these articles:
https://www.google.com/search?q=jquery+scroll+to+anchor+on+document+ready+site%3Astackoverflow.com
Anonymous(Private) June 22, 2020 at 3:29 pm #249652Awesome, thanks for helping with that search query. I should have guessed you guys are great at searching and filtering:)
Combining that with an if statement seems to be working well. Anyone needing a similar solution, please see below.
<script> jQuery(document).ready(function () { jQuery(window).load(function(){ if (window.location.href.indexOf('?_sft_') > 0) { ele = scrollToElement(jQuery('form#search-filter-form-177')); function scrollToElement(ele) { jQuery(window).scrollTop(ele.offset().top).scrollLeft(ele.offset().left); } } }); }); </script>
-
AuthorPosts