views:

1482

answers:

2

I am having a problem using thickbox and accordion on the same page ie none of them work. I have checked that they both use the latest version of jquery. Below are my includes. There are no other jscript files included. I am using this on a wordpress template if this can cause an issue.

<script type="text/javascript" src="<?php bloginfo('url'); ?>/wp-content/themes/foxintouch/javascript/jquery-1.3.2.min.js"></script>
<script type="text/javascript" src="<?php bloginfo('url'); ?>/wp-content/themes/foxintouch/javascript/jquery.accordion-1.2.2.js"></script>
<script type="text/javascript" src="<?php bloginfo('url'); ?>/wp-content/themes/foxintouch/javascript/jquery.accordion-1.2.2.source.js"></script>

<!-- thickbox -->

<script type="text/javascript" src="<?php bloginfo('url'); ?>/wp-content/themes/foxintouch/javascript/thickbox/thickbox.js"></script>
<link rel="stylesheet" href="<?php bloginfo('url'); ?>/wp-content/themes/foxintouch/javascript/thickbox/thickbox.css" type="text/css" media="screen" />

Here is the call to accordion:

$(document).ready(function () {
 $('#sidebar ul').accordion();
 });

The url to my site is http://clients.bionic-comms.co.uk/fox/foxintouch-wp/issue/13/wesco-new-range/ Any help would be much appreciated. Thanks

+1  A: 

I'm not sure why you're using the noConflict function on your site - this is intended to disable the $ shortcut in jQuery so it can be used with conflicting libraries like Prototype. Since your site only seems to be using jQuery based code, you don't need this.

Having the $ shortcut disabled is causing a fatal error in the code for Thickbox, which is in turn crashing the JS for the entire page.

Try getting rid of the noConflict code and just calling the accordian function directly, like so:

 $(document).ready(function () {
     $('#sidebar ul').accordion();
 });

Also, you shouldn't be including both jquery.accordion-1.2.2.js and jquery.accordion-1.2.2.source.js, just use the compressed version jquery.accordion-1.2.2.js by itself.

Tobias Cohen
Well, this fixes the thickbox issue but the accordion still won't play nice. It is permanently expanded.
Drew
Using firebug I also get an error saying "$("#sidebar ul").accordion is not a function".
Drew
I think the problem is that you have two jquery scripts. Try removing the "jquery.js" script.
brianpeiris
well accordion is working now but thickbox isn't any more!
Drew
Can you point out an example of where the thickbox is used on your site? I can't find any.
brianpeiris
http://clients.bionic-comms.co.uk/fox/foxintouch-wp/issue/13/wesco-new-range/
Drew
brianpeiris
thanks man! that sorted it out a treat. If you post an answer i'll vote you up
Drew
You're welcome, I'll post an answer shortly.
brianpeiris
+3  A: 

Your coded included references to two versions of jquery library. The first one (jquery-1.3.2.min.js) was extended with the accordion plugin but then it was overwritten by the second library (jquery.js).

This broke your $('#sidebar ul').accordion(); code because the second jquery library did not contain a definition for the accordion function (Only the first jquery library was extended with the accordion plugin).

Once you removed the second jquery library the thickbox stopped working because thickbox 3.1 does not support jQuery 1.3+ but this can be fixed easily by changing a single line in thickbox.js from:

TB_TempArray = $("a[@rel="+imageGroup+"]").get();

to

TB_TempArray = $("a[rel="+imageGroup+"]").get();
brianpeiris