This article is currently in the process of being translated into Vietnamese (~29% done).
Other frameworks and the noConflict() method
Khi bạn muốn làm việc với các framework khác trong trang trong khi vẫn dùng jQuery. Ví dụ rất nhiều gói JavaScript khác dựa trên JavaScript thông thường như ExtJS, MooTools ... Một số dùng ký tự $ giống jQuery và như vậy bạn có hai framework dùng cùng cú pháp, có thể làm cho chương trình lỗi. Nhưng rất may, jQuery có thể khắc phục bằng phương thức noConflict().
The noConflict() method simply releases the hold on the $ shortcut identifier, so that other scripts can use it. You can of course still use jQuery, simply by writing the full name instead of the shortcut. Here's a small example of it:
<div id="divTestArea1"></div>
<script type="text/javascript">
$.noConflict();
jQuery("#divTestArea1").text("jQuery is still here!");
</script>
If you think that "jQuery" is too much to type each time, you can create your own shortcut very easily. The noConflict() method returns a reference to jQuery, that you can save in your own little variable, for later use. Here's how it looks:
<div id="divTestArea2"></div>
<script type="text/javascript">
var jQ = $.noConflict();
jQ("#divTestArea2").text("jQuery is still here!");
</script>
If you have a block of jQuery code which uses the $ shortcut and you don't feel like changing it all, you can use the following construct. It's yet another version of the ready method, where $ is passed in as a parameter. This allows you to access jQuery using $, but only inside of this function - outside of it, other frameworks will have access to $ and you will have to use "jQuery":
<div id="divTestArea3"></div>
<script type="text/javascript">
$.noConflict();
jQuery(document).ready(function($)
{
$("#divTestArea3").text("jQuery is still here!");
});
</script>