Skip Navigation

[Resolved] Restricting scrollTop from all views

This support ticket is created 4 years, 5 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
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

Tagged: 

This topic contains 5 replies, has 2 voices.

Last updated by Ian Henderson 4 years, 4 months ago.

Assisted by: Shane.

Author
Posts
#1668505

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?

Many thanks in advance!

#1668849

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Ian,

Thank you for getting in touch.

Based on what is happening here it seems that you've add this JS to a general custom Javascript sheet.

Can you confirm that this was NOT added to the JS editor for the view that it is to be applied to ?

Thanks,
Shane

#1671861

Hi Shane

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.

best
Ian

#1672247

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Ian,

Re-add your code to your original view like this.

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.

Thanks,
Shane

#1686745

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.

#1686771

My apologies - found one more errant view with the generic jQuery - all working now. Thanks!