To resolve a conflict between jQuery and prototype,
is there any way other than asking jQuery to resolve via
jQuery.noConflict
and using jQuery
instead of $('code').code
;
Can't we ask prototype $
to step down and resolve.
To resolve a conflict between jQuery and prototype,
is there any way other than asking jQuery to resolve via
jQuery.noConflict
and using jQuery
instead of $('code').code
;
Can't we ask prototype $
to step down and resolve.
3 Answers
Reset to default 8You should namespace your code anyway, and jQuery gives you a good opportunity to re-claim the $
in the same step:
jQuery.noConflict();
jQuery(function ($) {
// $ is the jQuery object in here
// and doesn't conflict with Prototype
});
As described here.
I don't know if you can make Prototype "step down", but this is a perfectly elegant and working solution.
PrototypeJS adds a bit more to the global JavaScript namespace than jQuery does. For example, it adds meanings for: Ajax
, $
, $$
, $F
, Abstract
, Form
, $A
, $H
, $R
, $w
. You can look at a plete list of classes and utilities at api.prototypejs.
So the advice you've gotten is correct, There's no simple equivalent to jQuery.noConflict()
for PrototypeJS.
I can't find any function in http://api.prototypejs/ that will give back the $
, like noConflict()
in jQuery.
I wonder, what feature that you need so you still using prototype? jQuery might have plugins for that feature. Using 2 libraries in same page will make your page bloated by the size of each library.