1

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.

1 Answer 1

3

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

3
  • Thanks, so I better download slimbox 2 and use it togheter with mootools (a lot of joomla plugins use it). How do I use the noconflict, do I have to change every $ to JQuery?
    – Ruben
    Commented Apr 18, 2011 at 12:47
  • depends on your version of mootools. if you are on mootools 1.2.3+ then it's simple. just load jquery before you load mootools and mootools will drop to using document.id() instead of $. if you are on older mootools, then you need the noConflict and you need to load jquery afterwards. changing $ to jQuery will work or use a closure like (function($) { console.log($); // jQuery })(jQuery); around your code - keeping $ assigned to what it should be within the function. just careful about scope management. the reverse applies if mootools goes to document.id - just pass document.id above. Commented Apr 18, 2011 at 13:04
  • thanks man, it works without changing anything so jquery is probably loaded before mootools.
    – Ruben
    Commented Apr 18, 2011 at 13:09

Not the answer you're looking for? Browse other questions tagged or ask your own question.