views:

221

answers:

4

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;

Cant we ask prototype $ to step down and resolve.

+5  A: 

You 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.

deceze
RE separate answer: Yes, you can use jQuery as the conflict resolver.
deceze
A: 

I can't find any function in http://api.prototypejs.org/ 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.

Donny Kurnia
A: 

that means we can also use jQuery as conflict resolver. Right ? but not prototype

Gaurav M
Don't ask question here you can add comment to the related answer if you have any question about it. It may confuse reader looking for the real answer.
ali62b
okay. Yeah you are right
Gaurav M
A: 

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 complete list of classes and utilities at api.prototypejs.org.

So the advice you've gotten is correct, There's no simple equivalent to jQuery.noConflict() for PrototypeJS.

artlung