Tips and Tricks HQ Support Portal › Forums › WP Lightbox Ultimate › WP Lightbox Ultimate – jQuery error Uncaught TypeError Colorbox
Tagged: Colorbox Uncaught TypeError
- This topic has 9 replies, 2 voices, and was last updated 11 years, 6 months ago by wpCommerce.
-
AuthorPosts
-
October 20, 2012 at 1:31 pm #7692stucksterMember
Hi guys,
We have Colourbox enabled via the admin Library settings.
We are receiving a jQuery error on each page relating to Colorbox.
The code creating the error is
/* <![CDATA[ */
jQuery.noConflict();
jQuery(document).ready(function($){
$(function(){
$("a[rel='wp_lightbox_colorbox_image']").colorbox({The last line is causing the error…
Uncaught TypeError: Object [object Object] has no method 'colorbox'
Can you let us know what this means and how to fix it please?
October 21, 2012 at 2:21 am #50527wpCommerceModeratorCan you please share the link to the page where you are having this issue?
This error usually happens when there are multiple versions of jQuery. You can learn more about it here: https://support.tipsandtricks-hq.com/forums/topic/lightbox-ultimate-clicking-on-the-anchor-does-not-display-any-overlay
October 21, 2012 at 3:57 am #50528stucksterMemberIts occurring on several pages:
Homepage [http://www.connecttherapy.com] line 446
Blog [http://www.connecttherapy.com/blog] line 679
Pages [http://www.connecttherapy.com/our-products/] line 353
thanks
October 21, 2012 at 11:52 am #50529wpCommerceModeratorHi, I think this is the script that’s causing the issue (I also believe that it’s coming from your theme):
<script type='text/javascript' src='/wp-includes/js/jquery/jquery.js?ver=1.2.6'></script>
October 21, 2012 at 10:19 pm #50530stucksterMemberOk thanks. I’m sure we probably need that script to run our theme.
Is there a workaround? Why does it only cause problems for the Lightbox plugin but none of our other plugins?
October 22, 2012 at 2:25 am #50531wpCommerceModeratorYou don’t need that script to run your theme as long as Lightbox Ultimate is activated because Lightbox Ultimate is including another version of jQuery using the proper WordPress API.
<script type='text/javascript' src='http://www.connecttherapy.com/wp-includes/js/jquery/jquery.js?ver=1.7.2'></script>
This is the version of jQuery that needs to be included by any plugin or theme
http://codex.wordpress.org/Function_Reference/wp_enqueue_script
This API also makes sure that there is only one copy of the jQuery library even if multiple plugins include jQuery for their functionality.
Your theme is just hardcoding a very old version of jQuery (1.2.6) from the
wp-includes
folder (not using the WordPress API). So now there are multiple versions of jQuery on the same page.Right now if you install a plugin that requires the jQuery library I’m pretty sure It’s going to stop working.
October 22, 2012 at 2:40 am #50532stucksterMemberThanks.
I have commented out the reference to version 1.2.6 in our header
<!--<script type='text/javascript' src='/wp-includes/js/jquery/jquery.js?ver=1.2.6'></script>-->
but it’s unfortunately still returning the same error. Any other ideas?
October 23, 2012 at 3:30 am #50533wpCommerceModeratorHi, I still see an additional version of jQuery just before the commented line:
<script type='text/javascript' src='/wp-includes/js/jquery/jquery.js?ver=1.7.2'></script>
October 23, 2012 at 4:52 am #50534stucksterMemberYou said that version 1.7.2 “…is the version of jQuery that needs to be included by any plugin or theme” so I didn’t comment this out.
Anyway, I’ve now commented that line out as well and the error has gone away. However does this mean that our entire site is now dependant on the Lightbox plugin being activated?
October 24, 2012 at 2:35 am #50535wpCommerceModeratorI can’t tell you for certain if that jQuery is coming from Lightbox Ultimate. But that’s the right way to include jQuery to avoid conflict (Based on WordPress API).
Lightbox Ultimate doesn’t hardcode the jQuery library. It only requests WordPress to include jQuery if no other plugins have loaded it already. This is to make sure that there is only one copy of the jQuery library on a page.
If there is a plugin on your site which is loading before Lightbox Ultimate and using the same enqueue request (to include jQuery), WordPress will process that request first. Now when Lightbox Ultimate makes the same request WordPress will ignore it because one plugin has already included it.
So if you deactivate Lightbox Ultimate and see no jQuery 1.7.2 that means you don’t have any plugin which uses the enqueue function. In that case you will have to uncomment the line your theme has hardcoded.
-
AuthorPosts
- You must be logged in to reply to this topic.