Skip to content

Instantly share code, notes, and snippets.

@kovtunos
Forked from opi/gist:3247047
Last active September 29, 2017 14:07
Show Gist options
  • Save kovtunos/1fa93459c67eae16ae63bd66aed24431 to your computer and use it in GitHub Desktop.
Save kovtunos/1fa93459c67eae16ae63bd66aed24431 to your computer and use it in GitHub Desktop.
Prevent views_load_more to scroll #drupal #drupal7 #ajax
/**
* 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