Two jQuery plugin conflicting on the same page

六眼飞鱼酱① 提交于 2019-12-24 20:18:37

问题


I have two jQuery Plugins working on the same file. One is jquery.autocomplete.js and the other is jquery.thumbnailScroller.js .

The problem is when I am using both on same file, autocomplete is not working at all an thumbnailScroller is working and but the same is working well without thumbnailScroller plugin.

Now, when I was browsing thru the js files, I got $.fn. in both files. But, I dont know is the problem because of this or anything else.

I had searched in google and stackoverflow also, but I failed to get the proper solution. Please guide me


回答1:


There are some ways for avoiding conflict in jquery. I always do like this

var $k = jQuery.noConflict();

and use $k for every $ functions for any one plugin. Not do this in plugin js files. Do this for your implementation page, like,

$k("#id").autocomplete({... 

Regards

iijb



来源:https://stackoverflow.com/questions/13743578/two-jquery-plugin-conflicting-on-the-same-page

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!