Skip to content

Instantly share code, notes, and snippets.

@tlherr
Created December 4, 2013 16:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tlherr/7790280 to your computer and use it in GitHub Desktop.
Save tlherr/7790280 to your computer and use it in GitHub Desktop.
Using #attached to add javascript to a block/form element in drupal.
$block['content'] = array(
'#markup' => some_markup_function(),
'#attached' => array(
'js' => array('data' => drupal_add_js(drupal_get_path('theme', 'some_theme') . '/js/misc/somescript.js')),
),
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment