Imran
Imran

Reputation: 1104

How to remove Conflict in a jQuery plugin in a WordPress website?

I am working on a WordPress website. I have few filters of jQuery in it and all are working fine (I initiate these plugins using):

jQuery(document).ready(function($){
  /*code here*/
});

I am also using a jQuery Plugin "filter.js" which is having conflicting issues. Even when I do not initiate this plugin (only on linking the plugin file to my page) it shows jQuery conflict and I can see in console:

Uncaught TypeError: Cannot read property 'fn' of undefined 

You can find plugin source here.

Upvotes: 0

Views: 16453

Answers (2)

user2615436
user2615436

Reputation: 26

Are you using two different versions of JQuery in the same page?

If so then use

<script type="text/javascript">
jQuery.noConflict();
</script>

just after the declaring the jQuery and replace all subsequet $ with jQuery

Hope it helps

Upvotes: 0

tsdexter
tsdexter

Reputation: 2991

Try wrapping your code like this:

(function($){

    $(document).ready(function(){
         //document ready code here
    });

})(jQuery);

Wrap your filter.js plugin with the same wrapper, ie:

(function($){

    //filter.js code here

})(jQuery);

If that's not working - make sure jQuery is included on the page.

Upvotes: 5

Related Questions