两个jQuery脚本之间的冲突 [英] Conflict between two jQuery's scripts

查看:169
本文介绍了两个jQuery脚本之间的冲突的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是西班牙人(对不起,我的英语),这是我第一次在这里写信问问题.

I'm spanish (sorry for my english), and it's the first time that i write here for ask something.

经过数小时的调试并搜索了Fancybox脚本为何不起作用的原因,我在我的网站(现在处于维护模式)中搜索了两个脚本之间的冲突

After hours of debugging and searching why the Fancybox script didn't work i search a conflict between two scripts in my website (now in Maintence Mode)

我在网站上使用了一些脚本,但是可以肯定地说,这两个脚本之间存在冲突:

I use a few scripts on my website, but I can safely say that I have a conflict between these two scripts:

http://www.planetdescargas.com/wp-content/themes/bigfoot/javascripts/jquery.mousewheel-3.0.4.pack.js    
http://www.planetdescargas.com/wp-content/themes/bigfoot/javascripts/jquery.fancybox-1.3.4.pack.js

AND

http://www.planetdescargas.com/wp-content/plugins/buddypress/bp-themes/bp-default/_inc/global.js?ver=3.0.5

前两个脚本是jquery" fancybox "的插件,另一个是主要的javascript(Ajax) wordpress插件:BuddyPress.

The first two scripts is the plugin for jquery "fancybox", the other is the main javascript (Ajax) for wordpress plugin: BuddyPress.

后者在fancybox中造成冲突.如果我删除BuddyPress的脚本,fancybox会完美运行,但如果不能,fancybox则无法工作.

The latter creates conflict in fancybox. If I remove BuddyPress' script, fancybox works perfectly, but if not, fancybox don't work.

BuddyPress'脚本,global.js具有一开始就定义的变量,该变量是制作脚本的变量. 我尝试以这种方式定义它:

BuddyPress' script, global.js has a variable defined at the outset that is the one that makes the script. I try to define it this way:

var jq = jQuery.noConflict();

var jq = jQuery.noConflict ();

但仍然无法正常工作.

有什么建议吗?

在Firebug控制台中,我得到了:

In Firebug console i got this:

c.easing[this.options.specialEasing && this.options.specialEasing[this.prop] || a] is not a function

[定位器错误] e,this.options.orig [e]); this.options.c ... ++)ab || a.splice(b-,1); a.length | |

[Detener en este error] e,this.options.orig[e]);this.options.c...++)ab||a.splice(b--,1);a.length||

第143行

http://www.planetdescargas.com/wp-includes/js/jquery/jquery.js?ver=1.4.2

谢谢

推荐答案

只需使用这种方式即可.

Simply use this way.

打开wp-content/plugins/buddypress/bp-themes/bp-default/_inc/global.js

添加到顶部:

jQuery.noConflict (jquery_working =! html bind);

转到第#1264
在下面添加此内容:

Go to line #1264
Add this below:

;(function(jQuery){  ///Add this before start jQuery.easing.
  jQuery.easing.jswing=jQuery.easing.swing;jQuery.extend(jQuery.easing, {def:"easeOutQuad",swing:function(e,f,a,h,g){return ......
  // ...
})(jQuery); //Add this end of the call.

类似地,您可以解决jQuery Cookie插件冲突错误.

Similarly you can resolve the jQuery Cookie plugin conflict error.

这篇关于两个jQuery脚本之间的冲突的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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