Skip to content

Instantly share code, notes, and snippets.

@opi
Created August 3, 2012 12:15
Show Gist options
  • Save opi/3247047 to your computer and use it in GitHub Desktop.
Save opi/3247047 to your computer and use it in GitHub Desktop.
Drupal: prevent views_load_more to scroll
<?php
/**
* Implements hook_views_ajax_data_alter()
*/
function mymodule_views_ajax_data_alter(&$commands, $view) {
// Do not scroll when using views_load_more module
if ($view->query->pager->definition['handler'] == 'views_plugin_pager_load_more') {
foreach($commands as $k => $command) {
if ($command['command'] == 'viewsScrollTop') {
// Remove viewsScrollTop command
unset($commands[$k]);
// Alternatively, you can replace it your own command, by doing
// $commands[$k]['command'] = 'myOwnScrollCommand'
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment