I'll try to be a bit more clear.

There's a couple of simple rules. Whenever you include jQuery, it will
take anything already in the $ and jQuery variables and back them up
so it can install itself in the $ and jQuery variables. When you call
noConflict(true), jQuery (the version that is in the $ and jQuery
variables - i.e. the last version loaded) will take the backed up
library and put it back into the $ and jQuery variables, then return
you a pointer to itself.

If you're wanting to use two versions of jQuery as well as Prototype
on the same page, you'll need to call noConflict twice, and import
things in a certain order. I'm not sure how well this will work with
<script src="..."> blocks being loaded asynchronously (you'll need to
give it a good test) but it should work.

<script src="prototype.js"></script>
The $ function here will use prototype
<script src="jQuery114.js"></script>
jQuery loads and puts Prototype into backup variables (called _$). $
is now jQuery
<script>jq114 = jQuery.noConflict(true);</script>
The $ function is now prototype again. To use jQuery, use jq114()
instead.
This is where you're up to, if i'm understanding you correctly. now
you want to load jQuery 1.2.1
<script src="jQuery121.js"></script>
Prototype is now backed up in _$ (as it was in $ before) and jQuery
1.2.1 is in $
<script>jq121 = jQuery.noConflict(true);</script>
Prototype is now back in $ and jQuery 1.2.1 is in jq121.
So now, to use Prototype, you use the normal $(...) function. To use
jQuery 1.1.4, you use jq114(...) and to use jQuery 1.2.1 you use
jq121(...).

I've never tried loading three libraries and I'm no jQuery/Prototype/
JS pro but that might work. If not, I doubt I'll be of much use. You
might have problems loading plugins if jQuery isn't in a variable
called $ or jQuery. I've never tried so that's up to you I'm afraid.
If you can't get the code working, your best bet is probably going to
be to learn v1.1.4. Or just use 1.2.1 and get the plugin to provide
backward compatability with 1.1.4 for your Wordpress plugin. I only
jumped on board recently so I've not got much idea of what's different
between 1.1 and 1.2.

Hope this helps.

George.

On Oct 13, 11:35 pm, watermelongunn <[EMAIL PROTECTED]> wrote:
> Any chance someone could elaborate on what George explained?  It sort
> of makes sense to me, but I'm still a bit lost.  What would I do if a
> page I'm working on already has Prototype and JQuery 1.1.4 (loaded
> with noConflict()), and I wanted to then add JQuery 1.2.1 and some
> plugins?  Is that even possible or should I just learn how to use
> 1.1.4 (which is being loaded because of a few Wordpress plugins)?  I'm
> new to JQuery so I've been learning the latest build.  Is it very
> different from 1.1.4?  Sorry for the wide variety of questions.
>
> Any help or knowledge would be greatly appreciated.
>
> -Nicholas
>
> On Oct 9, 9:29 am, George <[EMAIL PROTECTED]> wrote:
>
> > After looking at the code it seems quite straight-forward. Someone
> > correct me if I've got the wrong end of the stick.
>
> > Summary: The first version you include will get reinstated, the second
> > version getting blown away.
>
> > How it works: When you include jQuery, it makes a copy of the window.$
> > and window.jQuery variables and puts them into _$ and _jQuery
> > (variables inside jQuery itself) respectively. So if there's already a
> > copy of jQuery included on the page (call it v1) and you go include
> > your second copy (call it v2), v1 will get 'backed up' into the _$ and
> > _jQuery variables inside v2 and the second copy you include will go
> > into window.$ and window.jQuery. At this point, if you use the $
> > function or the jQuery object, you'll be using v2. When you call
> > jQuery.noConflict(true), it will run against v2 because that's what's
> > in window.jQuery and it'll take the variables in _$ and _jQuery (which
> > are v1), put them back into window.$ and window.jQuery, and return you
> > a copy of v2 for you to put into a variable (called jQv2 for example).
>
> > At this point, window.$ and window.jQuery will be v1 and jQv2 will be
> > v2. So if you want to use v1, you carry on using $(...) or
> > jQuery.whatever(...) and if you want to use v2, you use
> > jQv2('#someId') or jQv2.whatever(...).
>
> > Hope this makes sense.
>
> > George.
>
> > On Oct 4, 12:27 am, "Glen Lipka" <[EMAIL PROTECTED]> wrote:
>
> > > We are making a jQuery+stuff script that will go on lots of random pages
> > > with unknown libraries.
> > > Some of those pages will have jQuery. (Variousversions)
>
> > > If I am including our script last; what is the best way to make sure our
> > > script doesn't interfere with any of the existing page, including old
> > >versionsof jQuery.
>
> > > Solution #1: We renamed jQuery in our script everywhere to be veryjQuery.
> > > Solution #2: ???
>
> > > Note: Solution #1 solved the problem, but feels invasive.  Is there a
> > > noconflict() way to do this?
>
> > > Glen

Reply via email to