Implementing Jquery in Joomla
February 5th, 2011
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 :
-
$document =JFactory::getDocument();
-
$document->addScript('location_to_jquery/jquery-min.js');
-
$scripts = "jQuery.noConflict()";
-
$document->addScriptDeclaration($scripts);
In Site :
from template :
-
<script type="text/javascript" src="<?php echo $this->baseurl ;?>/templates/<?php echo $this->template?>/js/jquery-min.js">
-
jQuery.noConflict();
-
</script >
-
// insert this code inside the <head> tag before <jdoc:include type="head" > tag
From module and component:
-
$document = JFactory::getDocument();
-
$document->addScript('location_to_jquery/jquery-min.js');
-
$scripts = "jQuery.noConflict()";
-
$document->addScriptDeclaration($scripts);