I downloaded a jQuery Lightbox2 library (not module, just a raw library) and added the following in my custom module:

drupal_add_js($libpath . '/js/jquery-ui-1.8.18.custom.min.js');
drupal_add_js($libpath . '/js/jquery.smooth-scroll.min.js');
drupal_add_js($libpath . '/js/lightbox.js');

But it causes an error like this (see below debug printscreen):

enter image description here

Could someone tell me, what to do to get rid of the error?

After some googling I installed the JQuery Dollar module but the error is still there. No clue what else to do.

4 Answers 4


on() was only added in jQuery v1.7; Drupal 7 ships with jQuery v1.4, and can be updated to 1.5 using the jQuery Update module. The reason you're getting the error is simply that the lightbox library you're using is written for jQuery v1.7 and above.

See How do I update jQuery to the latest version I can download? for some ideas on how to get round this.


In order to improve compatibility with other javascript frameworks, Drupal 7 requires to use a wrapper. Instead of $(document) in Drupal 6 it would be jQuery(document) in Drupal 7 (there are more options though).

Since you are not using the Lightbox2 module but just an external script it might not play along well. Although, I would rather expect the $ is not a function error message.


I think the 'on' function is a cousin of 'delegate', and was implemented in jQuery 1.7. Which version of jQuery are you using with your Drupal?


This is the easiest way to do it. Install this module:


Then add the following to your template.php:

function YOUR_THEME_preprocess_html(&$variables){
  drupal_add_library('jquery_plugin', 'tooltip');

And then you are free to add whatever javascript you want to your site as far as tooltip is concerned.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.