Search code examples
javascriptmootoolsprototypejsjavascript-frameworkconflict

Jquery, mootools and prototype in Joomla


Hi I need Mootools for my chronoforms, prototype for my lightbox 2 (I think) and maybe also some jQuery in the future.
When I enable Mootools, lightbox 2 is not working in IE, when I disable it, lightbox works fine but I get errors on my page from my chronoforms form.

Is there a good and easy way to make sure you don't get any problems using all three together?

And something like JQuery.noConflict() is not an easy solution.


Solution

  • You cannot have MooTools and Prototype co-exist.

    This is because they both change (extend) native host objects (Types) like Element (MooTools) and Array, Function, String, Number (both). You can't noConflict this for the life of you, each method can be defined once.

    It's going to be pot luck when you reference "foo".contains('oo') and it goes to String.prototype.contains (for instance) if you get Prototype's, Mootools or ES5's implementations (MooTools 1.5.1+).

    Time to reconsider what you use as you really should go to a single framework - they all can do what you need individually.

    You can also have MooTools + jQuery or Prototype + jQuery, however