Search code examples
jqueryjquery-pluginsconflictconflicting-libraries

Two jQuery plugin conflicting on the same page


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


Solution

  • 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