The below error occurs after a simple custom ajax event on one of my page. The error causes the attachBehaviors process to halt, which is problematic for any behaviors registered function that occurs after Colorbox's.
Uncaught TypeError: Cannot read property 'mobiledetect' of undefined VM5030:9
Drupal.behaviors.initColorbox.attach VM5030:9
(anonymous function) drupal.js?mxpowi:76
p.extend.each jquery.min.js?v=1.8.2:2
Drupal.attachBehaviors drupal.js?mxpowi:74
Drupal.ajax.commands.insert ajax.js?v=7.23:542
Drupal.ajax.success ajax.js?v=7.23:400
ajax.options.success ajax.js?v=7.23:164
k jquery.min.js?v=1.8.2:2
l.fireWith jquery.min.js?v=1.8.2:2
y jquery.min.js?v=1.8.2:2
d jquery.min.js?v=1.8.2:2
| Comment | File | Size | Author |
|---|---|---|---|
| #15 | colorbox_settings_2155657_15.patch | 1.17 KB | frjo |
| #13 | colorbox-unknown_settings_ajax-2155657-13.patch | 481 bytes | Koen.Pasman |
| #9 | fix-undefined-settings.patch | 961 bytes | Andrew211 |
Comments
Comment #1
FortEZ commentedThis is actually a rather important bug since it interferes with a lot of things in a website. Specifically, ajax requests in the View admin screen are not working, CKEditor is not loading, ajax requests in the panel administration are also not working etc.
The error log:
Uncaught TypeError: Cannot read property 'mobiledetect' of undefined colorbox_node.js?n13l1t:13
Drupal.behaviors.colorboxNode.attach colorbox_node.js?n13l1t:13
(anonymous function) drupal.js?n13l1t:76
e.extend.each jquery.min.js?v=1.7.1:2
Drupal.attachBehaviors drupal.js?n13l1t:74
(anonymous function) drupal.js?n13l1t:412
n jquery.min.js?v=1.7.1:2
o.fireWith jquery.min.js?v=1.7.1:2
e.extend.ready jquery.min.js?v=1.7.1:2
c.addEventListener.B
The same problem is also described here.
Is there some kind of workaround for this?
Comment #2
tce commentedI've just encountered this bug after adding a custom ajax form. I'm not sure if this is a correct fix, I'm no expert, but I made the following change and it seems to work:
In the file js/colorbox.js on line 9, I changed:
to:
Comment #3
tce commentedMaking the code run only once during page load also seems to fix it, though I don't know enough about the code to know if this will break the functionality.
Therefore, I'm sticking to my first workaround as it seems to me less likely to break anything.
Comment #4
alex.skrypnykPlease see attached patch
Comment #6
alex.skrypnykRe-rolling patch
Comment #7
alex.skrypnykComment #9
Andrew211 commentedHere's a patch that fixes up errors in colorbox_inline.js also.
Cheers
Comment #10
frobMarking this as needs review as to test the patch. Also setting the version to the dev branch.
Comment #11
frobThis doesn't follow Drupal coding standards. Drupal coding standards state that we should put the return; on a newline and enclose it inside {}. Also, this patch uses tabs and not spaces.
Comment #12
frobAfter applying the patch manually I noticed that it didn't actually solve the problem for me. For me the issue was also that there are no .colorbox elements on my site so the .once was calling .colorbox on an empty array and breaking things. What I ended up doing was a check to see if $(.colorbox).length returned 0.
Comment #13
Koen.Pasman commentedI rewrote the patch from #9 to using Drupal coding standards.
Comment #14
Koen.Pasman commentedAfter doing a little more digging I don't think this patch holds the solution.
I used this call:
Here, settings is set to an empty object, this will be used prior to calling the attachBehaviours in the 'insert' command. Removing the settings from this call solves it!
Correct:
And then, not patches are needed for the Colorbox module.
Comment #15
frjo commentedTesting for settings.colorbox should not break anything so no harm in adding it. Please test this patch, it fixes all the js files.
Comment #16
caminadaf commentedApplied the patch at #15 and it worked perfectly.
Comment #18
frjo commentedCommitted to 7-dev as well as 8-dev.