Skip Navigation

[Resolved] Toolset Pagination – return to top

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

Problem:
On a custom WordPress archive that includes pagination which updates via ajax, when the results are updated with the next page of results it should scroll back to the top of the page so that you are looking at the first of the new results.

Solution:
Add the following code to a custom JS section of the View or archive:

jQuery( document ).on( 'js_event_wpv_pagination_completed', function( event, data ) {
  jQuery("html, body").animate( {scrollTop: 0}, "fast");
});
This support ticket is created 6 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.

Sun Mon Tue Wed Thu Fri Sat
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+00:00)

This topic contains 2 replies, has 2 voices.

Last updated by dmitryK-2 6 years, 2 months ago.

Assisted by: Nigel.

Author
Posts
#606880
screen4.jpg
screen3.jpg

I am trying to: use the solution proposed here https://toolset.com/forums/topic/clicking-next-the-page-does-not-go-to-the-top-read-more-link-disappears/ for next page link jumps on top of next page in Shop page (controlled by Toolset Wordress Archive #48621 (see screens - 3 & 4)

Link to a page where the issue can be seen: hidden link

Can you please help to fix it, what is the right place to insert the code (or should code be corrected somehow)?

Chers!

#607014

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Hi there

I don't think the solution you are using is required for what you are aiming for.

If you simply want to scroll to the top when moving to another page of results (which update via ajax) then this alone should work:

jQuery( document ).on( 'js_event_wpv_pagination_completed', function( event, data ) {
  jQuery("html, body").animate( {scrollTop: 0}, "fast");
});

That code goes in the custom JS section of the Filter Editor or Loop Output section of your View.

#607733

Hi Nigel

I've inserted the code provided in JS editor of "Filter Editor" - thats works. Thank you!

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