Yang harus diperhatikan adalah bahwa jQuery menggunakan tanda $ sebagai shortcut untuk pemanggilan jQuery, sedangkan MooTools pun menggunakan $() sebagai shortcut untuk mempersingkat document.getElementById().
Jika kita meload jQuery dan MooTools secara bersamaan di satu halaman, maka bisa dipastikan bakalan terjadi konflik di antara keduanya.
Namun untungnya, kunci untuk mengatasi masalah tersebut sudah disediakan oleh jQuery, yaitu dengan menjalankan script jQuery.noConflict() setelah jQuery diload.
Kemudian di dalam script jQuery yang kita buat juga harus menggunakan jQuery sebagai pengganti $
<script type=text/javascript src=mootools.js></script> <script type=text/javascript src=jquery.js></script> <script type=text/javascript> jQuery.noConflict(); </script>
Jika pemanggilan menggunakan jQuery terasa terlalu panjang atau kurang keren, kita juga bisa membuat variabel sendiri sebagai penggantinya, misalnya sebagai berikut :
jQuery(document).ready(function() { jQuery('#content').html('Hello'); });
var test= jQuery.noConflict(); //lalu gunakan nama variabel tersebut sebagai pengganti jQuery test(document).ready(function() { test('#content').html('Hello'); });
6 :
David Walsh is Mozilla’s senior web developer, and the core developer for the MooTools
Javascript Framework. David’s blog reflects his skills in HTML/5, JS and CSS, and offers a ton
of engaging advice and insight into front-end technologies. Even more obvious is his passion
for open source contribution and trial-and-error development, making his blog one of the
most honest and engaging around.
Website: davidwalsh.name
David Walsh is Mozilla’s senior web developer, and the core developer for the MooTools Javascript Framework. David’s blog reflects his skills in HTML/5, JS and CSS, and offers a ton of engaging advice and insight into front-end technologies. Even more obvious is his passion for open source contribution and trial-and-error development, making his blog one of the most honest and engaging around.
Website: davidwalsh.name
David Walsh is Mozilla’s senior web developer, and the core developer for the MooTools Javascript Framework. David’s blog reflects his skills in HTML/5, JS and CSS, and offers a ton of engaging advice and insight into front-end technologies. Even more obvious is his passion for open source contribution and trial-and-error development, making his blog one of the most honest and engaging around.
Website: davidwalsh.name
David Walsh is Mozilla’s senior web developer, and the core developer for the MooTools Javascript Framework. David’s blog reflects his skills in HTML/5, JS and CSS, and offers a ton of engaging advice and insight into front-end technologies. Even more obvious is his passion for open source contribution and trial-and-error development, making his blog one of the most honest and engaging around.
Website: davidwalsh.name
David Walsh is Mozilla’s senior web developer, and the core developer for the MooTools Javascript Framework. David’s blog reflects his skills in HTML/5, JS and CSS, and offers a ton of engaging advice and insight into front-end technologies. Even more obvious is his passion for open source contribution and trial-and-error development, making his blog one of the most honest and engaging around.
Website: davidwalsh.name
David Walsh is Mozilla’s senior web developer, and the core developer for the MooTools Javascript Framework. David’s blog reflects his skills in HTML/5, JS and CSS, and offers a ton of engaging advice and insight into front-end technologies. Even more obvious is his passion for open source contribution and trial-and-error development, making his blog one of the most honest and engaging around.
Website: davidwalsh.name
Posting Komentar