Hi,
I use this function to scroll up, after the customers push any Ajax pagination, at the bottom of the search:
jQuery( document ).on( 'js_event_wpv_pagination_completed', function( event, data ) {
jQuery("html, body").animate( {scrollTop: 600}, 1000);
});
The problem is that I have also 4 Ajax search fields on top of the page, where customers can filter the search by different parameters.
Every time one of those fields value it's changed, the function starts and scroll down automatically, which is quiet annoying.
How can I avoid that?
Thanks
Hello, normally search filters do not trigger the js_event_wpv_pagination_completed event. I've set up a test here for you to review:
https://christ-27900-membership-1.discover-wp.com/events-test/
Click any of the pagination buttons to trigger the js_event_pagination_completed event and an alert will pop up. However, if you change the custom search filter, the alert is not triggered. Perhaps there is something else going on I'm not understanding. Is there a URL available where I can see the problem on the front-end of your site?
Found the problem but not the solution.
The weird scrolling wasn't caused by the jquery function, but from a slider view inserted at the bottom of the page.
Here you can see on top the search area with the dropdown fields and, at the bottom, the pagination numbers, followed by the slider.
hidden link
Try to change any of the search field or simply scroll to the page's bottom and wait.
Okay yes, sliders and slider Views are expected to trigger pagination events. The solution here is to use conditionals in your event hook callback that test which View is triggering the pagination event. You can see in the example I shared there is a parameter available 'data', which will provide access to data.view_unique_id. Each View will have a unique ID. You can use that in your event hook callback to determine which View has triggered the pagination event. You should only trigger your scrolling code if the main View triggers the pagination event.
That did the trick! Thanks!