Mootools扩展了“功能"功能.具有“扩展"类别的类.使jQuery无法使用的方法 [英] Mootools extends the "Function" class with an "extend" method making jQuery unusable
问题描述
Mootools扩展了"Function"类,并在其中添加了一个名为"extend"的新方法.现在,jQuery尝试使用jQuery.prototype.extend添加"extend"功能.但是,由于"extend"已经是jQuery对象的一部分(因为jQuery是Function类的对象),所以jQuery.prototype.extend不起作用. 有人在同时使用Mootools和jQuery时遇到过这种冲突吗?
Mootools extends the "Function" class and adds a new method called "extend" in it. Now jQuery tries to add "extend" function using jQuery.prototype.extend. However since "extend" is already a part of the jQuery object (since jQuery is an object of the Function class) so jQuery.prototype.extend doesn't work. Did anyone come across this conflict while using Mootools and jQuery simultaneously ?
更笼统地说,如果扩展了诸如函数,数组或对象"之类的本机类,我们是否有办法恢复为原始定义?
More generically, if a native class like "Function or Array or Object" is extended, do we have a way to revert back to the original definitions ?
推荐答案
我认为做到这一点的唯一方法:
The only way I can think to do that:
<script type="text/javascript">
// copy the original function
var ext = Function.prototype.extend;
// remove it
delete Function.prototype.extend;
</script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
<script type="text/javascript">
// Copy the jQuery version
var jqext = jQuery.prototype.extend;
// remove it (for sanity).
delete jQuery.prototype.extend;
// reassign the original function.
Function.prototype.extend = ext;
// remove the jQuery extend method (now the original Function.extend method)
delete jQuery.prototype.extend;
// reassign jQuery's original extend method.
jQuery.prototype.extend = jqext;
</script>
这篇关于Mootools扩展了“功能"功能.具有“扩展"类别的类.使jQuery无法使用的方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!