Skip Navigation

[Resolved] Scroll after pagination ONLY

This thread is resolved. Here is a description of the problem and solution.

Problem: I would like to trigger some custom JavaScript when pagination events are triggered by a specific View.

Solution: Use the JS event hook "js_event_wpv_pagination_completed" to trigger custom code. In the callback function, access the View's unique ID in the data parameter to target a specific View.

This support ticket is created 3 years, 2 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 4 replies, has 2 voices.

Last updated by Puntorosso 3 years, 2 months ago.

Assisted by: Christian Cox.

Author
Posts
#1920871

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

#1920965
Screen Shot 2021-01-27 at 1.26.16 PM.png

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?

#1921227

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.

#1921731

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.

#1930509

That did the trick! Thanks!

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.