Again, I’ve really been loving working with Toolset Types. One of the great things it lets me do is filter custom post types by various parameters. However, recently I was working on a site that had a huge list of parameters on the left sidebar and the results on the right. After I scrolled down to check off the correct parameters, I was forced to manually scroll back up to see the results. Of course, that is not optimal. But Toolset let’s you add js to your searches, so with a little js, I was able to make the page automatically scroll to the top after the results were filtered.
To do this, just find the JS editor under the filter editor box.
Here I have set the code to be triggered once the filter boxes have been checked, but you can also set other options, like pagination, using the little “frontend events” button. Here is the code I used:
jQuery( document ).on( 'js_event_wpv_parametric_search_results_updated', function() { /** * data.view_unique_id (string) The View unique ID hash * data.layout (object) The jQuery object for the View layout wrapper */ jQuery('html, body').animate({ scrollTop: 0 }, 'slow'); });
Leave a Reply