Reputation: 4921
I'd like to add the autocomplete to a joomla componenet that I'm developing I used JQuery I follwed this exemple
http://af-design.com/blog/2010/05/12/using-jquery-uis-autocomplete-to-populate-a-form/
The exemple work well but there is some problem
1 - When you add JQuery with joomla you have some problems with mootlools wen I added Jquery with this code
if(!JFactory::getApplication()->get('jquery'))
{
JFactory::getApplication()->set('jquery',true);
$document = JFactory::getDocument();
$document->addScript(JURI::root() . "administrator/components/com_tkcontrack/assets/js/jquery.js");
}
if(!JFactory::getApplication()->get('jquery.min'))
{
JFactory::getApplication()->set('jquery.min',true);
$document = JFactory::getDocument();
$document->addScript(JURI::root() . "administrator/components/com_tkcontrack/assets/js/jquery.min.js");
}
if(!JFactory::getApplication()->get('jquery-ui.min'))
{
JFactory::getApplication()->set('jquery-ui.min',true);
$document = JFactory::getDocument();
$document->addScript(JURI::root() . "administrator/components/com_tkcontrack/assets/js/jquery-ui.min.js");
}
I got some Javascript error with Mootools(thank's to firebug)
2 - Even I think some css does not work any more
Well can someone please help me to add autcomplete to joomla componene, and how to add JQuery to Joomla without having problem
Actually I tried to add JQuery with onther way, edit this file \libraries\joomla\document\html\renderer
but I does not work I have problem with Jquery then
Upvotes: 0
Views: 1693
Reputation: 585
replace above code with
JHtml::_('jquery.framework');
and in your js file start like this
jQuery(document).ready(function($) {
// your code goes here
}
to get ready-made code you can use JQUERY UI in ready
function
Upvotes: 0
Reputation: 19733
Not sure on what the error is exactly but it sounds like a conflict.
First of all, you're using the correct method to ensure your scripts only get imported once, however check Firebug see see if you only have 1 of each being imported just in case. You will then need to call noConflict like so:
$document = JFactory::getDocument();
$document->addScriptDeclaration( $noconflict );
What you could also do to import jQuery and jQuery UI only once and in noConflict mode is use the jQuery Easy Plugin:
One of the features that will apply to you is:
Hope this helps
Upvotes: 1