On the view embedded here: hidden link I have the following JS on the view in the search and pagination section to return to the top of the page after clicking on the pagination buttons:
jQuery( document ).on( 'js_event_wpv_pagination_completed', function( event, data ) {
/**
* data.view_unique_id (string) The View unique ID hash
* data.effect (string) The View AJAX pagination effect
* data.speed (integer) The View AJAX pagination speed in miliseconds
* data.layout (object) The jQuery object for the View layout wrapper
*/
jQuery('html, body').animate({ scrollTop: 450 }, 'fast');
});
Is there a way to make it only work on this view? On this page hidden link there is a View under 'Analysis' down around the middle of the page that has no JS added. However, the pagination buttons return to the top of the page, which I don't want here.
How do I stop this JS working on all pagination buttons?
This view was a copy of a view that had the JS added to the filter section. I then deleted that view and re-created it from scratch without the JS and it worked fine, but now the behaviour has returned. So yes, somehow it seems to be cached when it is used on another view and then applied to this view. Is this possible? I haven't added it anywhere else, as far as I'm aware.
jQuery( document ).on( 'js_event_wpv_pagination_completed', function( event, data ) {
/**
* data.view_unique_id (string) The View unique ID hash
* data.effect (string) The View AJAX pagination effect
* data.speed (integer) The View AJAX pagination speed in miliseconds
* data.layout (object) The jQuery object for the View layout wrapper
*/
if (data.view_unique_id === 13575) {
// block of code to be executed if the condition is true
jQuery('html, body').animate({ scrollTop: 450 }, 'fast');
}
});
Try adding it with the If statement so it only runs when this view is active.
Hi Shane - thanks for this, makes sense. However, I have gone through all views and replaced the jQuery with this specific one, and the view on hidden link is still jumping to the top of the page. Can this query be cached somewhere in Toolset, because that seems to be what is happening.