jQuery插件冲突 [英] Jquery plugin conflicts

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

问题描述

你们如何解决Jquery插件之间的冲突.如果两个或多个Jquery插件(例如文件上传插件)可以单独正常工作,但是当您包含第二个插件时,则会导致错误或意外行为.

How do you guys resolve conflicts between Jquery plugins. A conflict would be a situation where two or more Jquery plugins (such as a file upload plugin) work properly alone but result in errors or unintended behavior when you include a second plugin.

我现在遇到这个问题,我正在考虑使用iframe将网页的各个部分与其他所有内容隔离开来.但是,如果可能的话,我想避免这种情况.

I have this problem right now and I am considering using an iframe to isolate sections of my page from everything else. But I want to avoid this if possible to work out these conflicts.

对插件代码进行审核是不可行的,因为它需要大量的代码,并且需要考虑较短的开发时间.

Auditing the plugin code is not feasible its mountains of code and there are short development times to consider.

我不能使用jquery.noConflict,因为我必须将其触发,然后在我的代码的每一行中将$替换为Jquery.编辑插件是不可行的.我以为jquery.noConflict对插件不起作用?它仅适用于javascript/jquery库吗?我不喜欢图书馆.只是诸如滑块,画廊,文件上传器等之类的插件.

I can't use jquery.noConflict because I would have to fire it and then replace the $ with Jquery in ever line of my code. Editing the plugins is not feasible. I thought jquery.noConflict didn't work for plugins? It only works for javascript/jquery libraries? I'm not reffering to libraries. Just plugins like sliders, galleries, fileuploaders etc etc.

我用过:

(function($) {
jQuery.noConflict();

});

已经..

推荐答案

在网络上进行一些挖掘之后,我发现了一些资源

After some digging around on the web I found some resources

  1. Jquery插件冲突

如何解决此jQuery插件冲突?/a>

How do I solve this jQuery plugins conflict?

http://forum.jquery.com/topic/jquery-插件冲突

最后一个 http://www.jotform.com/help/130- Fixing-Jquery-Plugin-Conflicts-jCarousel

似乎每个人都建议使用noconflict,但最后一个说它起作用的人除外-我看不出它应该起作用的原因,因为

It seems that everyone suggest to use noconflict but except for the last one who said it worked - I don't see a reason it should work, since in documentations JQuery explains that it was meant for libraries that don't use JQuery but collide with it. ( see the 3rd resource I pasted here).

无论如何,似乎最好的选择似乎是深入研究代码并对其进行修改.

Anyway, it seems as if the best option is to dive into the code and modify it.

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

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