Archive

Posts Tagged ‘jquery conflict’

Implementing Jquery in Joomla

February 5th, 2011 prakash No comments

Joomla Uses Mootools as it’s javascript library by default, so we’ll need to use the jquery’s power of flexibility ie, jquery noConflict. Below are the examples how to use it.

In admin :

  1. $document =JFactory::getDocument();
  2. $document->addScript('location_to_jquery/jquery-min.js');
  3. $scripts = "jQuery.noConflict()";
  4. $document->addScriptDeclaration($scripts);

In Site :

from template :

  1. <script type="text/javascript" src="<?php echo $this->baseurl ;?>/templates/<?php echo $this->template?>/js/jquery-min.js">
  2. jQuery.noConflict();
  3. </script >
  4. // insert this code inside the <head> tag before <jdoc:include type="head" > tag

From module and component:

  1. $document = JFactory::getDocument();
  2. $document->addScript('location_to_jquery/jquery-min.js');
  3. $scripts = "jQuery.noConflict()";
  4. $document->addScriptDeclaration($scripts);