How to load Ajax Site Wide?

by Fahad   Last Updated January 18, 2018 15:07 PM

I am trying to open a webform in a modal window through following link, which works fine when I am logged in, but when I logout it simply stops working

<a class="use-ajax" data-dialog-options="{&quot;width&quot;:600}" data-dialog-type="modal" href="/form/call-back">Get a Call Back</a>

It seems like we need to load ajax on pages where we want to use this link, so I want to know how can I load ajax sitewide.

Answers 1

Implement hook_page_attachments_alter() like so:

function MODULE_page_attachments_alter(array &$attachments) {
  $attachments['#attached']['library'][] = 'drupal.ajax';

The same hook can be implemented in a theme if that makes more sense.

January 18, 2018 14:39 PM

Related Questions

Drupal 7 Custom Module with custom theme/template

Updated September 01, 2017 16:07 PM

Error with admin UI on /admin/structure/block

Updated May 05, 2015 21:03 PM

Where can I find my edit profile file

Updated March 02, 2018 22:07 PM

Is it possible to theme node add form in drupal 7

Updated July 13, 2015 15:03 PM