function hook_views_ajax_data_alter

Alter the commands used on a Views AJAX request.

Parameters

array $commands: An array of ajax commands.

\Drupal\views\ViewExecutable $view: The view which is requested.

See also

views_ajax()

Related topics

1 invocation of hook_views_ajax_data_alter()
views_ajax in drupal/core/modules/views/includes/ajax.inc
Menu callback to load a view via AJAX.

File

drupal/core/modules/views/views.api.php, line 611
Describes hooks and plugins provided by the Views module.

Code

function hook_views_ajax_data_alter(array &$commands, ViewExecutable $view) {

  // Replace Views' method for scrolling to the top of the element with your
  // custom scrolling method.
  foreach ($commands as &$command) {
    if ($command['method'] == 'viewsScrollTop') {
      $command['method'] .= 'myScrollTop';
    }
  }
}