Welcome on Kweetix Technical Blog

Tuesday, June 1, 2010

Solve conflict between JQuery and third party plugins

I recently had a problem with JQuery-UI (tabs) and JQuery Tools (scrollable) on a same page.

We can read on the web that this could be solved by generating a custom JQuery Tools script without tabs feature because the problem would be due to the fact that both script contains tabs feature. For me, that didn't solve the problem.

I solve my problem with the following method :

<html>
<head>

/* First include the third party script (example) */

<script type="text/javascript" src="js/jquery.tools.min.js"></script>

/* Then include JQuery and JQuery UI */

<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/jquery-ui.min.js"></script>

</head>
<body>
<script type="text/javascript">

$.noConflict();

jQuery(document).ready(function($)
{
// Code that uses jQuery's $ can follow here.

...
});

// Code that uses other library's $ can follow here.

$(function()
{
...
});

</script>
</body>
</_html>