Skip to content Skip to sidebar Skip to footer

Jquery And Mootools, .noConflict Is Failing

I have an application that requires the use of a mootools calendar, however, I use jquery for my main app structure. As soon as I have mootools in with jquery, neither work, and wh

Solution 1:

yes, the noConflict method should work, but if it doesn't or if you want to do it in another way, you should encapsulate the scripts in self-calling functions with the parameter being set as the main library object:

(function($){
    // al your jquery logic here
    alert($ instanceof jQuery);
})(jQuery)

after that, you should include the next library(in your case MooTools) and write the script normally , or - to be very sure - you can encapsulate the MooTools logic in a function as well.


Solution 2:

You should be fine if you simply call:

jQuery.noConflict();

...before including the Mootools JS file.

You can then use jQuery functions by using jQuery instead of $. Example:

jQuery('.selector').hide();  // instead of $('.selector').hide();

Solution 3:

You can also pass $ back in through the DOM-ready event:

$.noConflict();

// Non-jQuery code goes here

jQuery(document).ready(function($) {
    // You can now use the dollar sign safely inside of this function
}

Post a Comment for "Jquery And Mootools, .noConflict Is Failing"