Search code examples
javascriptjqueryprototypejs

(Javascript) Working with Prototype, multiple jQuery related libraries...?


I've seen a million different posts and (as odds would have it) a million different answers regarding how to include multiple jQuery libraries/plugins along with unrelated libraries/plugins. My main concern are the ones that require jQuery themselves.

Basically I'm using Prototype, jQuery, jQueryUI, and jQuery.dropshadow.js. Due to the requirements for Prototype, I obviously need to use "jQuery.noConflict()". However, this seems to break the other libraries. That leaves me wondering, in what order I need to include things and if I need to go back and replace the "$" in all the scripts with something else.

It would really be nice if these tutorial writers would start covering edge cases. Is it just me, or does it seem like they glaze over (or completely ignore) these hoping no one will use them?

Anyway, would someone mind explicitly detailing how to go about this?

Best.


Solution

  • The jQuery function (normally $) can be named anything and plug-ins handle that by wrapping themselves like this:

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

    If any plug-ins breaks when $ is named differently (jQuery.UI certainly does handle this), please contact the plug-in author because it's a bug.