You are here

function ajax_links_api_page_attachments in Ajaxify Drupal with JQuery Ajax 8

Implements hook_page_attachments().

Insert JavaScript to the appropriate scope/region of the page.

File

./ajax_links_api.module, line 17
Make any links or create new links via jQuery Ajax.

Code

function ajax_links_api_page_attachments(array &$page) {
  $config = \Drupal::config('ajax_links_api.admin_settings');

  // Get the positive/negative triggers for ajax links.
  list($trigger, $negative_trigger) = AjaxLinksApiSettingsForm::ajaxLinksApiGetTriggers();
  $page['#attached']['drupalSettings']['data']['ajax_links_api'] = array(
    'html5' => $config
      ->get('ajax_links_api.html5'),
    'vpager' => $config
      ->get('ajax_links_api.vpager'),
    'trigger' => $trigger,
    'selector' => $config
      ->get('ajax_links_api.selector'),
    'negative_triggers' => $negative_trigger,
    'scripts_included' => $config
      ->get('ajax_links_api.scripts_included'),
  );
  $page['#attached']['library'][] = 'ajax_links_api/ajax_links_api';
}