jQuery和Mootools可以一起使用吗? [英] Can jQuery and Mootools work together?

查看:78
本文介绍了jQuery和Mootools可以一起使用吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

jQuery和Mootools可以一起工作吗?

Can jQuery and Mootools work together??

如果不是那样的话?

推荐答案

除了noConflict之外,还有更多其他功能.

There's more to it than just noConflict.

jQuery是一个侵入式库.它将内部jQuery123(对于123的每个实例的某个随机实例值)属性添加到它接触的每个元素(其中包括数据或事件处理程序的任何内容).在IE中,此属性也反映为属性.

jQuery is an intrusive library. It adds an internal jQuery123 (for some randomised per-instance value of 123) property to every element it touches (which is anything with data or event handlers, amongst other reasons). In IE, this property also gets reflected as an attribute.

因此,如果MooTools或任何其他库(或者确实是普通的DOM方法)出现并开始使这些属性/属性,克隆元素或黑客入侵innerHTML,那么它们很可能会弄乱这些-唯一的标识符,导致jQuery变得混乱,并开始以异常难以调试的方式开始行为异常.

So if MooTools or any other library (or indeed, a plain DOM method) comes along and starts messing with those properties/attributes, or cloning elements, or hacking innerHTML, they're likely to mess up these supposedly-unique identifiers, causing jQuery to get confused and start misbehaving in ways it is extraordinarily difficult to debug.

jQuery还伪装了许多事件代码,以尝试使commit/focus/blur/focusin/focusout/mouseenter/mouseleave事件在浏览器中正常工作和冒泡.这可能会使其他不希望使用的库代码变得混乱.

jQuery also fiddles a bunch of event code to try to make submit/focus/blur/focusin/focusout/mouseenter/mouseleave events work and bubble across browsers. This may confuse other-library code that is not expecting it.

因此,使用jQuery 1.4,只要它们正在处理彼此不交互的单独元素,就几乎可以同时使用另一个库. (jQuery 1.3对其接触"了哪些元素也更加混杂.)

So, with jQuery 1.4, you can just about get away with using another library at the same time, as long as they are working on separate elements that don't interact with each other. (jQuery 1.3 was also much more promiscuous about what elements it ‘touched’.)

但是总的来说,我不会在一页上推荐两个主要框架.

But in general I would not recommend two major frameworks on one page.

这篇关于jQuery和Mootools可以一起使用吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆