Conflicts can occur with other JavaScript libraries if you don't take the proper precautions when writing your jQuery. Most conflicts occur with the use of the $ alias, which Prototype also shares as an alias. You need to take two steps to eliminate conflicts with others libraries:
+ Add the noConflict function at the end of your jQuery Library. The noConflict
function releases all dependability of the jQuery on the $ alias back to any other libraries
that are also using it.
$.noConflict();
+ Change all references of the $ alias to the jQuery alias as demonstrated in the following example. Change this:
$(document).ready() {
//code goes here
});
To this:
jQuery(document).ready() {
//code goes here
});
You can also define your own alias if you don't wish to use the jQuery alias. This is done by adding a line of JavaScript to define your own alias. In the following example, I set up the new alias as $delphinidin, instead of just $. It's that easy!
var $delphinidin = jQuery;
$delphinidin(document).ready() {
// code goes here
});
0 comments:
Post a Comment