开发者

Mootools extends the "Function" class with an "extend" method making jQuery unusable

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>


Have you tried jQery.noConflict ? http://api.jquery.com/jQuery.noConflict/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜