Views has been updated to scroll to the top of the view results when Ajax is enabled. Normally this isn't a problem, since the standard ajax behavior is to replace the existing view results with the new view results.

However, since Views Load More appends the new results to the bottom of the existing ones, it should also intercept and stop the scroll behavior. As it currently stands, Views Load More appends new content, then Views scrolls the user to the top of the view so the new content is not seen.

Members fund testing for the Drupal project. Drupal Association Learn more


justin2pin’s picture

Status: Active » Needs review
819 bytes

Looks like the "viewsScrollTop" command just needs to be removed for views using the Views Load More pager. The attached patch removes the command in hook_views_ajax_data_alter().

ericduran’s picture

Status: Needs review » Needs work
+++ b/views_load_more.moduleundefined
@@ -30,7 +30,11 @@ function views_load_more_views_ajax_data_alter(&$commands, $view) {
+    foreach ($commands as $key => $command) { ¶

Lets just remove the extra space.

Once that's fix this look good to me.

heylookalive’s picture

+1 This works great for me.

jyee’s picture

Status: Needs work » Reviewed & tested by the community
818 bytes

While I appreciate the attention to detail and Drupal coding standards, it took about 70 keystrokes to write a message telling someone to remove the space when you could've simply hit one to remove it.

ericduran’s picture

Status: Reviewed & tested by the community » Fixed

Actually the previous comment took about 2 seconds to write. The patch would had taken some time since I was going to have to apply it, fix it, etc..

It's also good practice for people to know the coding standards as every other maintainer would do the same thing. ;-)

Thanks for the patch :).

This is now fixed.


Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

pawel.traczynski’s picture

6.22 KB

Hi everyone. In Drupal 6 or 7 if you want to disable the views ajax scrolling to top you can simply override views javascript attached behaviour. Grab the ViewsAjaxView piece of code from vajax_views.js (located in views module directory). Copy the code of the behaviour into your theme's javascript file and comment out the line responsible for scrolling:

if ( - 10 < $(scrollTarget).scrollTop()) {
  $(scrollTarget).animate({scrollTop: ( - 10)}, 500);

so it becomes:

if ( - 10 < $(scrollTarget).scrollTop()) {
  //$(scrollTarget).animate({scrollTop: ( - 10)}, 500);

Please note that doing this will disable ajax views scrolling to top for all ajax enabled views.

Don't forget to clear you cache if you added new javascript file to your theme in file.

Attached is the file with behaviour override that i used. Views 3.0.

sheijtel’s picture

Version: 7.x-1.x-dev » 7.x-1.1

That solution is not valid anymore. They made a big improvement I think, and just adding this to your theme javascript file will do the job.

-------- removed code, will add an attachment in following post -------

sheijtel’s picture

Attachment is better

sheijtel’s picture

993 bytes


AdamGerthel’s picture

Doesn't work for me. I'm only having this problem on iOS though (mobile safari). Has anyone managed to solve that?

treckstar’s picture

This patch worked great for me, thanks!

kermaleivos’s picture

A glance here..

Just today I made a workaround by setting viewScrollTop to null in my custom javascript file i.e.:


	  if (Drupal.ajax)
	 	 Drupal.ajax.prototype.commands.viewsScrollTop = null;


By doing this, I don't have to make changes straight to the module. And anyways this is just one workaround before the module handles this itself.

ryanissamson’s picture

Looks like there's a few options - can someone shed some light on the best method for disabling the scroll to top?

Spec0’s picture

Drupal Gardens users cannot modify core or module files so one can add custom code similar to this to prevent the scroll animation:

/* Views Ajax Content Load Autoscroll Feature Disabled */
        //On page load
        jQuery('.pager-item a.views-ajax-scroll-processed').click(function(){
		jQuery('body, html').stop();
        //Again after ajax request is completed
		jQuery('.pager-item a.views-ajax-scroll-processed').click(function(){
			jQuery('body, html').stop();
Piratawww’s picture

Issue summary: View changes

#13 works for me! Thx

jeremypeter’s picture

For Drupal 8 you can add this to your JS to stop execution:

  Drupal.AjaxCommands.prototype.viewsScrollTop = null;  

Or you can override the functionality:

  Drupal.AjaxCommands.prototype.viewsScrollTop = function(){
    // Code to run here
cheermartha’s picture

#17 Thx !!! :)