Question by CitPat: Multiple JavaScript Libraries don’t play nice?
I am just learning JavaScript using libraries, but with the examples I have I’ve noticed they don’t play nice when more than one is used, ie. JQuery, Mochi, Scriptalicous. Is there a way to encapsulate them to just affect the area they are needed and not the entire webpage? Or am I stuck to just one at a time per page?
Best answer:
Answer by Chris B
jQuery has a noConflict function to resolve normal javascript to jQuery conflicting each other.
Hope this helps!
If you need further assistance/advice, feel free to contact me.
Give your answer to this question below!
load the library in no conflict mode, most have this functionality check the docs
use this:
(function($ ){
$ .jqueryFunction();
})(jQuery);
(function($ ){
$ .anotherLibFunction();
})(anotherLib)
this way you can use the $ shortcut even with different libraries
anyway, is better if you learn to use well at least one, you can do with jquery anythig you can do with others while cut and paste programmers tend to mix