Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using prototype with Jquery

Is there any way of using prototype to coexist with Jquery.

What i mean is not Jquery with prototype with the Jquery NoConflict tag but the other way around.

I have to override prototypes utility methods to coexist with other libraries?

I have no control over the Jquery Scripts

like image 605
Jet Abe Avatar asked Feb 04 '26 18:02

Jet Abe


1 Answers

When jQuery is included, it takes a copy of whatever is defined as $ and stores a reference to it. When you use jQuery.noConflict it restores that reference, and returns jQuery which allows you to "rename" jQuery.

If you want to rename Prototype, that should be entirely possible.

// 1. include Prototype
//    $ == Prototype
// 2. include jQuery
//    $ == jQuery

var jq = jQuery.noConflict();
var $p = $;
$ = jq;

// now, $ == jQuery
// and $p == Prototype
like image 78
nickf Avatar answered Feb 07 '26 15:02

nickf



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!