javascript, jQuery, Mootools, Prototype

Make jQuery work on the same page with Mootools and or Prototype

, , , on June 25, 2008
Make jQuery work on the same page with Mootools and or Prototype

Some conflicts appear when using jQuery javascript library with Motools or Prototype on the same page. A workaround is using noConflict mode for jQuery.

Follow these steps:

1. Download the latest version of jQuery

2. Download jQuery compat

3. Open jquery.js, go to the end of the file and add this line jQuery.noConflict();

4. With jquery.js opened, open jquery.compat-1.0.js copy all it's content and paste-it after jQuery.noConflict(); line in jquery.js.

5. Find these lines and comment or delete them:

jQuery.fn._filter = jQuery.fn.filter;
jQuery.fn.filter = function(arr){
  return this._filter( arr.constructor == Array ? arr.join(",") : arr );
};

6. Open all .js files that use jQuery library and add as the first line (function($){ and as the last line })(jQuery);

(function($){
content of the .js file
})(jQuery);

That's it.

Arpit's picture

Thanks pal, I was struggling with this conflict for long time. You solution helped me out.

Thanks

Arpit


justburnin's picture

outstanding... that did just the trick. kudos chap.


Post new comment

The content of this field is kept private and will not be shown publicly. If you have a Gravatar account associated with the e-mail address you provide, it will be used to display your avatar.