Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 UTC on 18 March 2024, to get $100 off your ticket.
Hi guys
I was wondering if it is possible to load libraries via the #attached property from render arrays.
Cheers
Hi guys
I was wondering if it is possible to load libraries via the #attached property from render arrays.
Cheers
Comments
Comment #1
jm.federico CreditAttribution: jm.federico commentedAh, and if so, if any one of you could provide an example. Thankx
Comment #2
Solthun CreditAttribution: Solthun commentedNot sure if this is what you meant exactly but this is an example that works:
http://api.drupal.org/api/drupal/includes!ajax.inc/group/ajax/7#comment-...
Comment #3
jm.federico CreditAttribution: jm.federico commented@Solthun
Thanks for the link, it works with libraries registered with Drupal Core library functionality, but can't get it to work with libraries registered with Library Api module.
Cheers
Comment #4
Jelle_SYes it's possible:
So, in short, just add a
libraries_load
key to your#attached
array, with as value an array of parameters to pass to libraries_load().Comment #5
jm.federico CreditAttribution: jm.federico commentedThanks!!!!!
Comment #7
Jaypan CreditAttribution: Jaypan commentedNote that this:
Should be this:
Comment #8
Jelle_S@Jaypan:
No it should not ;-)
See drupal_process_attached():
The second argument to call_user_func_array() should be an array :-).
Comment #9
Jaypan CreditAttribution: Jaypan commentedOh, you're right. I had an additional array layered in my code I was working on.