I am trying to: automatically scroll to the top of the view, which is in an element with the id of $results, after the "next" or "prev" links are clicked to paginate using Java. (I'm now realizing the title I gave this issue doesn't match the issue I'm describing here).
I visited this URL: hidden link
I expected to see: The page scroll to the top of the #results area after clicking the "next" or "prev" links.
Instead, I got: The page stayed in the same spot - at the bottom of the #results area.
Here's what I have at this point. I'm using the JS Editor within the Filter Editor for the view. I clicked the "Frontend events" button which loaded the 'js_event_wpv_pagination_completed' function and I inserted my jQuery inside it. Here it is in it's entirety:
jQuery( document ).on( 'js_event_wpv_pagination_completed', function( event, data ) {
jQuery('html, body').animate({ scrollTop: $('#results').offset().top }, 100);
});
It's not working and I'm not sure why. If I just use the following it will take it to the top of the page, or I can change the pixel amount to offset it, but I want it to go straight to the top of the element with the id #results.
jQuery( document ).on( 'js_event_wpv_pagination_completed', function( event, data ) {
jQuery('html, body').animate({ scrollTop: 0 }, 'slow');
});
Any help you can offer is greatly appreciated!
Geeze - I figured it out. I wasn't paying attention to the "$" that needed to be "jQuery"