[Drupal/jQuery] Using multiple jQuery versions on the same page

Data dodania wpisu: 17-11-2010

This note doesn't concerns only Drupal CMS. It does on all Content Management Systems using jQuery older than 1.4 family. But take our point on bluedrop:)

The last stable Drupal - 6 - uses jQuery 1.2.6 (either 1.3.2 after jQuery Update module installation). However, if our template effects require latest jQuery (1.4), there are several problems with Drupal jQuery based user interface elements, like ie. tabledrag. The point is to load latest jQuery before Drupal jQuery loads and put this into a javascript variable. This var will be used in a template jQuery methods.

The code should look like this way::

<script type="text/javascript" src="jQuery.1.4.4.js"></script>
<script type="text/javascript">var $j = jQuery.noConflict();</script>
<script type="text/javascript" src="jquery.min.js"></script>
<script type="text/javascript">
  $j(document).ready(function(){
    alert($j().jquery); // alert does inform about custom loaded jQuery version - 1.4.4 here :)
  });
</script>

That's the solution to use multiple jQuery version on the same page without any annoying conflicts;)

Comments

I much prefer informative articles like this to that high brow litertuare.
Comments closed...

DesignEnd on Facebook

Inspiration