mootools_Mootools和jQuery之间的冲突导致脚本停止工作

mootools

Both jQuery and Mootools offer some nice, easy to use scripts. Mootools is best known for their interactive slideshows and jQuery for their menus, but both have many other uses as well.  

jQuery和Mootools都提供了一些不错的,易于使用的脚本。 Mootools以其交互式幻灯片和jQuery菜单而闻名,但它们也有许多其他用途。

jQuery is basically a toolkit with many DOM-related features while Mootools is more modular. They conflict because they have a few identically named functions and namespaces and as a result one or both scripts don't work, or at least don't work properly. In my experience it usually it is Mootools that loses out in this deal.

jQuery基本上是具有许多与DOM相关的功能的工具包,而Mootools则更具模块化。 之所以会发生冲突,是因为它们具有一些同名的函数和名称空间,结果一个或两个脚本无法正常工作,或者至少无法正常运行。 以我的经验,通常是Mootools在这笔交易中输了。

There are several workarounds available to make jQuery and Mootools work together. Some call for editing the core scripting of jQuery and others call for modifying your script, mostly just to avoid conflict with the "$" function that both rely on heavily. I tried several of these in the past, none worked that well and most just plain broke the script entirely. Maybe it was my fault for not implementing the changes properly, I dunno. I would post those here but it may confuse some who, like me, sometimes just skim pages looking for code snippets to fix what they already have.

有几种解决方法可以使jQuery和Mootools一起工作。 有些人要求编辑jQuery的核心脚本,而另一些人则要求修改脚本,主要是为了避免与都非常依赖的“ $”函数冲突。 过去,我尝试了其中的几种方法,但没有一种能很好地工作,大多数只是简单地将脚本完全破坏了。 我不知道这可能是我未能正确实施更改的错。 我会在此处发布这些内容,但可能会使某些人(如我)感到困惑,有时他们只是浏览页面以查找代码片段以修复现有内容。

After trying the hard way numerous times I found a very simple addition to jQuery scripts that makes it free up constants and variables so that other modules, like Mootools, can use them. In the simplest of terms you tell jQuery to not conflict.

在无数次尝试之后,我发现jQuery脚本非常简单,可以释放常量和变量,以便其他模块(例如Mootools)可以使用它们。 用最简单的术语来说,您告诉jQuery不要冲突。

Just add the following little line to the very top of your Jquery script(s), right after the script tag.

只需在script标签之后,将以下几行添加到Jquery脚本的顶部即可。

<script type="text/javascript" language="javascript">
jQuery.noConflict();

// your script here

</script>

This method will usually make Jquery and Mootools play nice together with the least amount of headache. It has worked for me many times.

这种方法通常可以使Jquery和Mootools一起玩,并且头痛最少。 它为我工作了很多次。

翻译自: https://www.experts-exchange.com/articles/3099/Conflict-between-Mootools-and-jQuery-causes-script-s-to-stop-working.html

mootools

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值