两个 jQuery 脚本之间的冲突
我是西班牙人(抱歉我的英语),这是我第一次在这里写信询问一些事情。
经过几个小时的调试和搜索 Fancybox 脚本不起作用的原因后,我在我的网站上搜索了两个脚本之间的冲突(现在处于维护模式),
我在我的网站上使用了一些脚本,但我可以肯定地说我之间存在冲突这两个脚本:
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 插件:巴迪出版社。
后者在 fancybox 中造成冲突。如果我删除 BuddyPress 的脚本,fancybox 可以正常工作,但如果没有,fancybox 将无法工作。
BuddyPress 的脚本 global.js 在一开始就定义了一个变量,该变量是生成脚本的变量。 我尝试这样定义它:
var jq = jQuery.noConflict ();
但仍然不起作用。
有什么建议吗?
在 Firebug 控制台中我得到了这个:
c.easing[this.options.specialEasing && this.options.specialEasing[this.prop] || a] is not a function
[Detener en este error] e,this.options.orig[e]);this.options.c...++)ab||a.splice(b--,1); a.长度||
第 143 行
http://www.planetdescargas.com/wp-includes/js/jquery/jquery.js?ver=1.4.2
致谢
I'm spanish (sorry for my english), and it's the first time that i write here for ask something.
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
The first two scripts is the plugin for jquery "fancybox", the other is the main javascript (Ajax) for wordpress plugin: BuddyPress.
The latter creates conflict in fancybox. If I remove BuddyPress' script, fancybox works perfectly, but if not, fancybox don't work.
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 ();
But still not working.
Any suggestions?
In Firebug console i got this:
c.easing[this.options.specialEasing && this.options.specialEasing[this.prop] || a] is not a function
[Detener en este error] e,this.options.orig[e]);this.options.c...++)ab||a.splice(b--,1);a.length||
Line 143 of
http://www.planetdescargas.com/wp-includes/js/jquery/jquery.js?ver=1.4.2
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
只需使用这种方式即可。
打开
wp-content/plugins/buddypress/bp-themes/bp-default/_inc/global.js
在顶部添加:
转到行 #1264
添加如下:
同样可以解决 jQuery Cookie 插件冲突错误。
Simply use this way.
Open the
wp-content/plugins/buddypress/bp-themes/bp-default/_inc/global.js
Add on top:
Go to line #1264
Add this below:
Similarly you can resolve the jQuery Cookie plugin conflict error.
这不是您使用 jQuery.noConflict() 的方式。
noConflict()
释放对$
符号的控制。从我从您的其他脚本中看到的情况来看,它们使用安全的方式 ((function($){ }(jQuery))
) 因此使用noConflicts()
没有实际的影响。把它改成
这样:
为了确定。
文档: http://api.jquery.com/jQuery.noConflict/
That's not how you use
jQuery.noConflict()
.noConflict()
releases control of the$
symbol. From what I see from your other scripts though, they use the safe way ((function($){ }(jQuery))
) so usingnoConflicts()
has no actual effect.Change this
into this:
To make sure.
Documentation: http://api.jquery.com/jQuery.noConflict/
我不知道出了什么问题,但我解决了问题。我在主题根目录的functions.php中使用此代码:
我从名为 Easy Fancybox,现在一切正常。谢谢!
I don't know what was wrong, but i solved the problem. I use this code in my functions.php in my theme root:
I took the libraries from a wordpress plugin called Easy Fancybox, and now all work fine. Thanks!