Hi there
We have a search page where I use this code to scroll to the results when changing the search:
jQuery( document ).on( 'js_event_wpv_parametric_search_results_updated', function() {
jQuery('html, body').animate({ scrollTop: jQuery("#search-results").offset().top-180}, 'slow');
});
Now I'd like to use the same effect when coming to the search results page from a search field placed on a different page. We have a search field on our main page. But when opening the search results page, it doesn't scroll. I Is it possible to add the ID as an anchor in the shortcode?
{!{wpv-form-view name='only-search' target_id='123'}!}
Where I have "123" I would like to be able to set the URL including the ID, e. g. /search-page#search-results.
It that possible?
Thanks for your help.
Shane
Supporter
Languages:
English (English )
Timezone:
America/Jamaica (GMT-05:00)
Hi Marcial,
Thank you for getting in touch.
Based on what you're saying the search results page is different from the search page itself.
Do it like this.
jQuery( document ).ready(function() {
jQuery('html, body').animate({ scrollTop: jQuery("#search-results").offset().top-180}, 'slow');
});
The scroll should now activate when you navigate to the page after it has fully loaded.
Please let me know if this helps.
Thanks,
Shane
Thanks a lot, that works perfect!