This question is specific to D7:
I'm trying to load in jQuery UI modal into the theme. I've put the following in my THEMENAME_preprocess_html
:
$variables['page']['content']['#attached']['library'][] = array('system', 'ui.dialog');
This isn't loading the library at all.
DPM-ing the $variables
array after the above line shows that it's all added correctly (There's even other stuff in there like, addthis.js):
Direct link: https://i.sstatic.net/6iC3h.png
Obviously all caches were cleared. At this point the console shows an error that dialog is not defined
. But as soon as I add this (in the same function, just below the #attached
line):
drupal_add_library('system', 'ui.dialog');
then the dialog modal opens and starts playing nicely. Am I doing something wrong with #attached? I'm really puzzled as to why one's working and the other doesn't. Ideally I'd like to use #attached
in the cases where the variables array gets cached and the preprocess doesn't get called.