Jet Abe
Jet Abe

Reputation: 23

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

Upvotes: 2

Views: 581

Answers (3)

Jet Abe
Jet Abe

Reputation: 420

I just changed every occourence of $ to pType in prototype and dependent libraries

Added them as secondary assets for this use case.

Done!

Upvotes: 1

nickf
nickf

Reputation: 546025

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

Upvotes: 8

Aaron Butacov
Aaron Butacov

Reputation: 34327

No, there isn't.

Upvotes: 0

Related Questions