PDA

View Full Version : jQuery 1.2.x breaks all JS



MoscowModder
02-09-2009, 04:20 PM
1) Script Title:
Animated Collapsible DIV (2.1)

2) Script URL (on DD):
http://www.dynamicdrive.com/dynamicindex17/animatedcollapse.htm

3) Describe problem:
The problem is that jQuery 1.2.x destroys all the functionality of every script on my page. It has a lot of javascripts that are all essential. I've pinned the problem on jQuery. Even the collapsible div script is broken. It's an interactive page, but nothing is clickable with jQuery linked to it. When I remove the jQuery link, everything else works.

Thanks in advance!

jscheuer1
02-09-2009, 06:14 PM
Sounds like a conflict with another library like prototype or mootools.

Please post a link to the page on your site that contains the problematic code so we can check it out.

MoscowModder
02-10-2009, 06:25 AM
I don't use any other Javascript libraries; just jQuery. And it breaks all of my interactive scripts.

Unfortunately, I have not acquired hosting for this site yet. For the moment, it's just a fun thing.

jscheuer1
02-10-2009, 06:49 AM
Well you can try running jQuery in no-conflict mode. Place it as the first script on your page, make the animatedcollapse.js script the second. At the top of animatedcollapse.js, make it like so:


//** Animated Collapsible DIV v2.0- (c) Dynamic Drive DHTML code library: http://www.dynamicdrive.com.
//** May 24th, 08'- Script rewritten and updated to 2.0.
//** June 4th, 08'- Version 2.01: Bug fix to work with jquery 1.2.6 (which changed the way attr() behaves).

var animatedcollapse;
(function($){
animatedcollapse={
divholders: {}, //structure: {div.id, div.attrs, div.$divref}
divgroups: {}, //structure: {groupname.count, groupname.lastactivedivid}
lastactiveingroup: {}, //structure: {lastactivediv.id}

and at the end:


setCookie:function(name, value, days){
if (typeof days!="undefined"){ //if set persistent cookie
var expireDate = new Date()
expireDate.setDate(expireDate.getDate()+days)
document.cookie = name+"="+value+"; path=/; expires="+expireDate.toGMTString()
}
else //else if this is a session only cookie
document.cookie = name+"="+value+"; path=/"
}

}
})(jQuery);

MoscowModder
02-10-2009, 01:52 PM
(Edit: I misspelled the jquery.js file link and now that it's changed, the original problem is back.)

Well, re-arranging the scripts ends the script-breaking, but animatedcollapse doesn't work.

Without the changes to animatedcollapse.js, Firebug gives me this error:
$divref is null
{path}/js/animatedcollapse.js
Line 42

With the changes you described:
animatedcollapse is undefined
javascript:animatedcollapse.show(4);
Line 1

What's wrong now?

By the way, all of the javascript files are in a /js/ folder from index.html

MoscowModder
02-10-2009, 02:43 PM
Turns out I misspelled the filename of jQuery-1.2.6.pack.js. I fixed that and the original problem returned. Now what?

jscheuer1
02-10-2009, 03:30 PM
Can you get the Animated Collapsible DIV v2.01 script to run on a page with only its scripts and jQuery on it? If not, you either have a bad copy of jQuery or are doing something else wrong.

If it's not simply a bad copy of jQuery, I'd really need to see a demo of the problem. Make one and upload it to the web, post the address to it here.

MoscowModder
02-10-2009, 03:38 PM
I know it worked before, and then it inexplicably stopped working. I've downloaded and re-downloaded both animatedcollapse.js and jquery-1.2.6.pack.js multiple times. I'll try making a new page to see if it works.

MoscowModder
02-10-2009, 04:03 PM
How odd. The demo page works perfectly with the same scripts!

jscheuer1
02-10-2009, 04:53 PM
Sort of like a case of going to the doctor and suddenly feeling better. Can you copy your live page as local and will it work? Are you getting any error messages or warnings locally?

MoscowModder
02-10-2009, 05:15 PM
Now the only problem is getting the content from the real page to the demo page, without the bugs.

MoscowModder
02-11-2009, 04:28 PM
I will try copying stuff a bit at a time and see what causes the problem.

MoscowModder
02-17-2009, 06:36 AM
More mystery: I replaced one script (CSS Horizontal menu) with a similar script (Smooth Navigation Menu) which uses jQuery. That one script works for some bizarre reason.

MoscowModder
02-18-2009, 05:37 PM
I have found the root of the problem. You cannot click on certain sections of the page. Something transparent with a high z-index is covering everything!

How laughable.

Thanks for your help!