Skip to content

Instantly share code, notes, and snippets.

@mrded
Created October 28, 2013 13:03
Show Gist options
  • Save mrded/7196450 to your computer and use it in GitHub Desktop.
Save mrded/7196450 to your computer and use it in GitHub Desktop.
Drupal agreement: Working with JS variables.
(function ($) {
Drupal.behaviors.moduleName = {
attach: function(context, settings) {
console.log(settings.module_name.foo); // bar
}
};
})(jQuery);
<?php
$setting = array(
'module_name' => array(
'foo' => 'bar'
),
);
drupal_add_js($setting, 'setting');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment