简体   繁体   中英

Jquery plugin conflicts

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.

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.

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.

I used:

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

});

Already..

After some digging around on the web I found some resources

  1. Jquery Plugin conflict

  2. How do I solve this jQuery plugins conflict?

  3. http://forum.jquery.com/topic/jquery-plugins-conflict

And the last one http://www.jotform.com/help/130-Fixing-Jquery-Plugin-Conflicts-jCarousel

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.

i had an issue with jquery conflict, but my case was i had also used prototype.js. i worked out a solution for that. here is a pointer checkout if it helps.

jquery conflict occurs when "$" is also used by some other plugins. hence we need to define jQuery.noConflict

so that all the methods are called using some other reference in this case 'jQuery'.

try include the scripts files on the page as follows.

  1. include all the jQuery files (library and all plugins which are dependent on jquery).
  2. fire jQuery.noConflict();
  3. include all other libraries/ plugins.
  4. wherever jquery methods are called use "jQuery" istead of "$"

hope this helps you out..

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM