You are here

function jquery_dollar_js_alter in jQuery Dollar 7

Same name and namespace in other branches
  1. 8 jquery_dollar.module \jquery_dollar_js_alter()

Implements hook_js_alter(). This function will add a js file immediately after drupal.js that declares: $ = jQuery; This allows all other code to use the $ convention for writing jQuery code The reason is that forcing users to use special closures to make jQuery compatible with the $ are superfluous, confusing, and complicated. More here: http://drupal.org/node/1407256

File

./jquery_dollar.module, line 12

Code

function jquery_dollar_js_alter(&$javascript) {
  $file = drupal_get_path('module', 'jquery_dollar') . '/jquery_dollar.js';

  // Copy all properties of drupal.js.
  $javascript[$file] = $javascript['misc/drupal.js'];

  // Replace the file to load.
  $javascript[$file]['data'] = $file;

  // Minimally increase the weight to be loaded directly after drupal.js.
  $javascript[$file]['weight'] += 0.1;
}