Skip to content

Instantly share code, notes, and snippets.

@pete-otaqui
Created October 6, 2011 10:48
Show Gist options
  • Save pete-otaqui/1267113 to your computer and use it in GitHub Desktop.
Save pete-otaqui/1267113 to your computer and use it in GitHub Desktop.
Multiple jQueries have different Events
<!DOCTYPE html>
<html>
<head>
<title>Multiple jQuery Hell</title>
<script src="jquery-1.6.3.min.js"></script>
<script>
// keep a reference to jQuery 1.6.3, and clear the name from the global scope
jQuery163 = jQuery;
jQuery.noConflict(true);
</script>
<script src="jquery-1.6.4.min.js"></script>
<script>
// keep a reference to jQuery 1.6.4, and clear the name from the global scope
jQuery164 = jQuery;
jQuery.noConflict(true);
</script>
<script>
// check that we have two distinct jQueries
console.log(jQuery163().jquery); // 1.6.3
console.log(jQuery164().jquery); // 1.6.4
// we could use either for the onDomReady bit ...
jQuery163(function() {
// bind a click event callback
jQuery163('a').bind('click', function() {
console.log('clicky!');
});
// now try and unbind it
jQuery164('a').unbind('click'); // this doesn't unbind the click event callback
});
</script>
</head>
<body>
<h1>Multiple jQuery Hell</h1>
<a href="#">Clicky</a>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment