Closed (outdated)
Project:
Drupal core
Version:
7.x-dev
Component:
documentation
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
7 Sep 2012 at 00:21 UTC
Updated:
23 Apr 2021 at 12:46 UTC
Jump to comment: Most recent
Comments
Comment #1
jhodgdonIn calling drupal_add_js() directly, normally the data is passed in via the $data argument, not as part of $options. Then the function drupal_js_defaults() takes $data and puts it into $options. So yes you *could* put data into $options directly, but there is no real reason to, since it's a separate argument. I don't think we need to document it that way.
Comment #2
solotandem commentedYes, normally data is passed in via the $data argument, but in the situation where the $data is an array and drupal_add_js is being invoked from the form API "#attached" property, then $data must be NULL and the "data" key must be included in $options. So, unless someone can dispute that reasoning, does it not argue the "data" key should be added to the documentation?
Comment #3
jhodgdonOK, just needs a patch! :) Probably a good novice issue...
Comment #12
quietone commenteddrupal_add_js was removed from Drupal 8.0 in #2368797: Optimize ajaxPageState to keep Drupal 8 sites fast on high-latency networks, prevent CSS/JS aggregation from taking down sites and use HTTP GET for AJAX requests. Changing version