Gen
15
Posted on 15-01-2008
Categories: ajax, conflitti, javascript, trucco - Author: Mat on 15-01-2008

They’re very powerful ajax libraries but…what happens when you use them together? There are some conflicts because they all override $ function.
So if you want to use different libraries that are using both JQuery, Prototype and Mootools, like Lightbox, Slimbox, Thickbox, JSValidate or something else, you can use noConflict function. It’s only a JQuery feature, so you can use JQuery with Prototype or JQuery with Mootools. I never tried Prototype with Mootools but it seems there isn’t still a similar function like noConflict in these libraries.
This is the code you can set for calling JQuery:

<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">var $JQ = $; //rename $ function</script>

and then you must use the new prefix, $JQ, insted of $ for every JQuery call. For example, if you’re using Thickbox just replace every instance of $ with $JQ inside thickbox.js

Sources:
JQuery
Davide Salerno
Filippo Pisano


 

Comments

bio on 24 Settembre, 2008 at 21:45 #

Quando affrontai il problema, non ho trovato il tuo articolo.
Sembra che alla fine le conclusioni sono le stesse, per tentativi ho trovato il plugin thinkbox risolutore del problema.
Grazie per il commento sul mio sito.


Thalia on 9 Aprile, 2009 at 00:28 #

Thank you so very much. This is exactly what I needed.


daniel on 26 Giugno, 2009 at 22:53 #

uso varias librerias..y tuve ese problema entre libs pero tu sol q das esta amedias en thickbox.js añadele lo sig $j=jQuery.noConflict(); y cambia todos los $ por $j y funcioinara yo uso thickbox, jquery y mootools y otritas mas y jala bien


Post a Comment
Name:
Email:
Website:
Comments: