Using prototype with Jquery

此生再无相见时 提交于 2019-12-11 03:35:15

问题


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


回答1:


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



回答2:


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

Added them as secondary assets for this use case.

Done!




回答3:


No, there isn't.



来源:https://stackoverflow.com/questions/3089471/using-prototype-with-jquery

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!