Pages

Search This Blog

Wednesday, October 7, 2009

using jquery in Joomla

I'm developing a joomla component for joomla and involve jquery. It will hit error and need to take special care because joomla ship with javascript framework "MooTools" which will have conflict with jquery.

Here is the code that i pun into my view.html.php

$document =& JFactory::getDocument();
$document->addScript(JURI::base(true).'/components/com_xin/js/jquery-1.3.1.min.js');
$document->addScriptDeclaration ( 'jQuery.noConflict();');
$document->addScript(JURI::base(true).'/components/com_xin/js/validation.js');

in the validation.js

I change all the $ to jQuery.

For example i change
$(document) to jQuery(document)
$('#login') to jQuery('#login')
and all others.

Test again and it works. Hope this help.

No comments: