Prototype.js / jQuery conflict

228 views
Skip to first unread message

dizzyjay

unread,
Feb 5, 2009, 6:48:39 PM2/5/09
to Prototype & script.aculo.us
Is there a way to resolve this conflict within prototype? My portal
uses jQuery and I'm the only developer with a preference of
prototype.js. I've tried the jQuery.noConflict() with no luck. I
don't want to abandon my prototype.js skillset for jQuery but it's
looking like I'm the one that needs to find the workaround if I want
to continue with prototype.js

(NOTE: I've also tried the find/replace '$' with '_$' method....
didn't work- broke a good amount of functionality)

thanks in advance
dj

david

unread,
Feb 6, 2009, 2:22:32 PM2/6/09
to Prototype & script.aculo.us
Hi dizzyjay,

the noConflict function works great, but the problem I think is that
you rename the jquery object, so all other developper will have to
change there scripts to no use anymore the $ function (by defaul
$==jquery).

some times ago, a protosafe library was developped, but it has
stopped .... so I'm not sure there is a way to resolve your problem.

--
david

Matt Foster

unread,
Feb 6, 2009, 3:24:47 PM2/6/09
to Prototype & script.aculo.us
This is completely theoretical, and probably even more ludicrous as I
think of it being plausible cross-browser...

But in theory if you did something like this

var A = function(){ alert("First definition");}

A();

var A = function(){ alert("Second definition"); };

A();

Would behave as such, so that you could load jquery and all dependent
scripts first, then load prototype and all of its dependent scripts
subsequent to that and get away with it? Give it a shot and let us
know...

dizzyjay

unread,
Feb 6, 2009, 3:35:37 PM2/6/09
to Prototype & script.aculo.us
Not sure I quite understand the suggestion (please explain). If I end
up revisiting the jquery code, I'll probably just use the
jquery.noConflict() function and reassign the embedded jquery $()
refernces to something different. Too bad I can't do the same with
the prototype code; there's a lot less of it, and I'm in control of
the scripts... the jquery changes have me at the mercy of the portal
developer.
> > > dj- Hide quoted text -
>
> - Show quoted text -

dizzyjay

unread,
Feb 6, 2009, 3:38:07 PM2/6/09
to Prototype & script.aculo.us
Thanks- this looks like what I'll need to do. Hopefully the portal
owner will be accepting of the change. Too bad prototype doesn't have
the same conflict workaround (it would be much easier for me to
change).

cheers,
\\dj

bminihan

unread,
Feb 9, 2009, 10:25:19 AM2/9/09
to Prototype & script.aculo.us
If you don't have a lot of Prototype code, and that's within your
control...you should be able to convert your existing prototype code
to jQuery syntax, then get rid of Prototype entirely. We looked at
doing this when we started mixing jQuery into our code, but we had WAY
too much Prototype to make that an easy project. I investigated the
conversion process tho, and it didn't actually look terribly
difficult...I think the Scriptaculous effects required the most syntax
work =]

Good luck!

Dj

unread,
Feb 9, 2009, 12:02:12 PM2/9/09
to prototype-s...@googlegroups.com
I've started down that road... they're more similar than I originally
thought. I know it's blasphemous, but I kinda like some of the jquery
syntax (although it seems limited) any pitfalls to watch for while
converting?

Regards,
dj

Alex Mcauley

unread,
Feb 9, 2009, 1:27:51 PM2/9/09
to prototype-s...@googlegroups.com
You can assign for instance $jq=jQuery.noConflict(); after you have loaded
the jQuery library .... it works well with most of the plugins i have used
as i mix and match my proto && Jquery in functions, i htink only in one
jquery plugin did i have to go and change $() to $jq() to make it work, i
have been using prototype and jquery together for over a year and never had
any prolems with naming and namespaces ... but i do assign it to $jq

Good luck

Alex
Reply all
Reply to author
Forward
0 new messages