Log in

View Full Version : Resolved Conflict jQuery



rexi
08-29-2012, 06:33 PM
Hello,...
Any solution for conflict two js.jQuery file on same page.
I have problem with :

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>

and this

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>

Thank you.

djr33
08-29-2012, 07:25 PM
There's not going to be any easy way around that at all, at least not without modifying one of the scripts, meaning that you'd then end up having one incompatible with whatever other scripts use it.

You should reduce it to just one. Why do you want both?

I can imagine two situations:
1. You want to use two different scripts, and each requires a certain version of jQuery. In this case, one of the scripts will be updated. But generally that difference (just a .1 difference) shouldn't be something you can't work out, at least for one script or the other.
2. For some reason, you don't have complete control over the page and one version of jQuery is already included, but you need another one. You'll have to find some way to stop the first one, but I don't have any ideas on this without having more information.

jscheuer1
08-29-2012, 07:28 PM
It depends upon the other scripts' code that use those. Generally anything that uses 1.3.2 can use 1.4.2, and probably they can both use 1.7.2 (latest I'm aware of).

What I would try is getting rid of the second one on the page and replacing the first one on the page with:


<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js"></script>

which selects the latest available in the 1.7.x series.

There can be other problems and not all code that uses older libraries will work well with the newer one, though sometimes older code works better with the newer library, more cross browser. Usually there's no noticeable difference.

One thing to look out for is that one or more of your scripts that uses jQuery may have this:


jQuery.noConflict()

in it. If it does, that should be commented out:


//jQuery.noConflict()

The browser cache may need to be cleared and/or the page refreshed to see changes.

If you want more help, please include a link to the page on your site that contains the problematic code so we can check it out.

rexi
08-29-2012, 09:53 PM
Thanks both guys,....
I am using long time "magnifier"for images,..and I want put new script "expstickybar",..and that is problem conflict between.
Mr.John,..I am try your solution,but for me not working, or I am not understood well.
This is page (http://ddr10.blogger.ba/) for example.

jscheuer1
08-29-2012, 11:08 PM
As far as I can tell, you haven't even followed the instructions for the scripts involved.

Anyways, here's a demo:

http://home.comcast.net/~jscheuer1/side/rexi/jq_h.htm

rexi
08-30-2012, 12:15 AM
Thank you John,..but still no change.I think that is problem server of blog.On your empty HTML working perfect,..but on my page no.No problem about that,..I will move out one from them.
Thanks.

jscheuer1
08-30-2012, 01:29 AM
Well, the sticky bar does require a standards invoking DOCTYPE. And the way you have it configured, at least an empty stickybarcontent.htm file in the same folder as the page. Those two are part of what I was saying about not following the instructions for the scripts. At least the magnifier is working.

There are some other issues, but let's try fixing those two and see what happens. Put this:


<!DOCTYPE html>

as the very first thing in the source code of the page, and upload an empty file called stickybarcontent.htm to the same folder.

The browser cache may need to be cleared and/or the page refreshed to see changes.

rexi
08-30-2012, 02:49 AM
Thank you,..
Same situation.I put "doctype" on the top,..and also I put "stickybarcontent.htm".
Link (http://ddr10.blogger.ba/)

jscheuer1
08-30-2012, 03:06 AM
Same situation . . . and also I put "stickybarcontent.htm" . .

Nope that file:

http://ddr10.blogger.ba/stickybarcontent.htm

is still a 404 Not Found.

And from the error message I'm getting in Firefox at least, it looks like that's all that's missing. You can also remove:


<script type="text/javascript">
var mystickybar=new expstickybar({id:"stickybar",position:'top',revealtype:'mouseover',peekamount:30,externalcontent:'stickybarcontent.htm',speed:300})
</script>

Because that or similar is already in the main stickybar script. But having it twice shouldn't be causing it not to work at all.

rexi
08-30-2012, 04:23 AM
Sorry for that,..this is just blog,..not web site and I can't make any htm.
This code is not causing problem,..I used because,I can change "peekamount" without editing main js.file.


<script type="text/javascript">
var mystickybar=new expstickybar({id:"stickybar",position:'top',revealtype:'mouseover',peekamount:30,externalcontent:'stickybarcontent.htm',speed:300})
</script>
Thank you for your help and time for me.

jscheuer1
08-30-2012, 04:30 AM
It doesn't just change it, it makes a second one, or tries to. The thing to do is to get rid of the one on the page, and edit the one in the script - Or get rid of the one in the script and edit the one on the page. Either way you're wanting to get rid of all references to the external file. So get rid of one, make the other like so:


var mystickybar=new expstickybar({id:"stickybar",position:'top',revealtype:'mouseover',peekamount:30,externalcontent:'',speed:300})


That way you won't need the stickybarcontent.htm file.

rexi
08-30-2012, 05:20 PM
Hello John,..
You are right about this code that causing problem,..but not all:


var mystickybar=new expstickybar({id:"stickybar",position:'top',revealtype:'mouseover',peekamount:30,externalcontent:'stickybarcontent.htm',speed:300})

Now, it's working both on the page,but I am move out this script:


<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js"></script>

and I am put back old two:



<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>

It is very strange and sensitive,..If I put first (1.3.2/jquery) above (1.4.2/jquery),..that is no work.
But if I put (1.4.2/jquery) above (1.3.2/jquery),..that is working.

It is looking like that:


<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript" src="http://yourjavascript.com/3212001831/stickybar.js">
/***********************************************
* Expandable Sticky Bar- (c) Dynamic Drive (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for this script and 100s more.
***********************************************/
</script>


<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript" src="http://yourjavascript.com/9063801232/jquery.magnifier.js">
/***********************************************
* jQuery Image Magnify- (c) Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for this script and 100s more
***********************************************/
</script>

But is not work oposite like that:


<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript" src="http://yourjavascript.com/9063801232/jquery.magnifier.js">
/***********************************************
* jQuery Image Magnify- (c) Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for this script and 100s more
***********************************************/
</script>


<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript" src="http://yourjavascript.com/3212001831/stickybar.js">
/***********************************************
* Expandable Sticky Bar- (c) Dynamic Drive (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for this script and 100s more.
***********************************************/
</script>


This page (http://ddr10.blogger.ba/),...Thank you very much.

jscheuer1
08-30-2012, 06:00 PM
That's odd, but understandable in a weird way. How about trying with only 1.4.2:


<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript" src="http://yourjavascript.com/3212001831/stickybar.js">
/***********************************************
* Expandable Sticky Bar- (c) Dynamic Drive (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for this script and 100s more.
***********************************************/
</script>


<script type="text/javascript" src="http://yourjavascript.com/9063801232/jquery.magnifier.js">
/***********************************************
* jQuery Image Magnify- (c) Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for this script and 100s more
***********************************************/
</script>

rexi
08-30-2012, 07:40 PM
Wow,..it's working with only 1.4.2/.
Great job Mr.John,..Very,very thank you for help and time.
This case can be resolved,but I can't find how make "resolved",..because new system on the forum change it??