I've been developing an AJAX module for a client that needs to run on both Drupal 5 and Drupal 4.7. Unfortunately, the jQuery 4.7 module uses the now well outdated 1.0.3 version of jQuery and I was finding a number of incompatibilities cropping up between the more recent Drupal 5 version and the older Drupal 4.7 version.
Here's a simple way to bring your Drupal 4.7 up to date with the current version of jQuery, and to allow for simple upgrades when new versions of the library are released.
The really, really quick version
- download the latest version of jQuery (you'll probably want to choose the compressed version)
- rename the downloaded .js file to jquery-modified-compressed.js and replace the existing file of the same name in your jQuery47 module directory
-
open jquery-modified-compressed.js and add the following line to the end of the file:
var JQ = jQuery.noConflict(); - Enjoy!
The kinda-cleaner-depending-on-how-you-look-at-it version
Preferring not to alter the existing jQuery47 module as it really isn't needed when using this approach, I opted instead to recreate the drupal47_add_js function in the site's existing custom module and remove the drupal47 module altogether.
This is just a matter of adding the following function:
function jquery47_add_js($file) {
$jquery = drupal_get_path('module', 'my_module_name') . '/jquery.js';
drupal_add_js($jquery);
drupal_add_js($file);
}Where my_module_name is, of course, the name of your custom module, and your downloaded jQuery javascript library is renamed to jquery.js and dropped into the same directory as your module.
Note that the name of the function (jquery47_add_js) is important, as this is the function name that contrib modules which rely on the jQuery library will call.






The jQuery documentation says that noConflict() does not define what is returned, so I'm not sure you need the
var JQ =part of your javascript statement. i.e. just append to the jquery.pack.js file the following line:jQuery.noConflict()I encourage readers to take a look at the docs of this function: http://docs.jquery.com/Core#.24.noConflict.28.29
I used this method on a client's site 2 weeks ago, but didn't get a chance to write it up. Good tip!