Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
My colorbox is throwing the following Javascript error whenever I click on a colorbox-enabled image on the home page:
$.data(this, colorbox) is undefined
The offending code (on line 208 of the uncompressed Javascript) is this:
var relRelated = $.data(this, colorbox).rel || this.rel;
Strangely, the colorbox code works fine on individual node pages.
Comments
Comment #1
frjo CreditAttribution: frjo commentedDo you have en example site where we can see this problem
Can you replicate it on a clean install.
Comment #2
jennifermontes CreditAttribution: jennifermontes commentedMy site is live here: http://jennifermontes.com/
I'll try a clean install on my local machine and see what happens.
Comment #3
jennifermontes CreditAttribution: jennifermontes commentedOkay, I tried a clean install and Colorbox works fine... So that means there must be some kind of conflict with another module (*sigh*). I tried deactivating many of my modules and then clearing caches but no dice, so now I'm hunting around for where this could be coming from.
Starting from my original error in the Firebug console whenever I click on a Colorbox-enabled image: $.data(this, colorbox) is undefined. When I try the code without using the '$' shortcut, and specifying the 'colorbox' variable as 'jQuery.colorbox' I don't get an error anymore:
If I try to put the code that's throwing the error inside some code that re-associates '$' with jQuery, like this:
the console still complains, like so: ReferenceError: colorbox is not defined.
Honestly, I'm stumped. The lines previous to the one throwing the error use the '$' shortcut without any error and a few lines before that the 'colorbox' variable is being used without needing the 'jQuery.' prefix. What's happening? And why only on the front page?
Comment #4
frjo CreditAttribution: frjo commentedA guess, but do you have some jQuery script that is not wrapped in:
Comment #5
jennifermontes CreditAttribution: jennifermontes commentedMaybe, but how could I find it?
Comment #6
frjo CreditAttribution: frjo commentedDeselect "Bandwidth optimization" for JavaScript files in the performance settings.
Look up all the JS files that are loaded on the front page.
Firefox with the Firebug plugin or Safari with the developer tools activated etc. are a good help in this.
Comment #7
frjo CreditAttribution: frjo commented