I tried to include the JQuery lib into joomla but it’s not working. Many comps and modules use mootools inside my CMS. I think the problem is a conflict between the two frameworks.
I have searched the internet and found some articles but the following code is still not working as expected.
<?php
JHTML::stylesheet('demo_page.css', 'media/system/css/');
JHTML::stylesheet('ftab.css', 'media/system/css/');
JHTML::stylesheet('demo_table.css', 'media/system/css/');
$option="com_mycomp";
$base=JUri::root().'components/'.$option.'/js/';
$document=&JFactory::getDocument();
$noConflict="jQuery.noConflict();";
//$document->addScriptDeclaration($noConflict);
$document->addScriptDeclaration("jQuery(document).ready(function($){jQuery('#example').dataTable();});");
JHTML::script('jquery.js',$base,true);
$document->addScript($base,'jquery.js');
$document->addScript($base,'jquery.dataTables.js');
?>
This should sort my table using JQuery but it does not.
How do I use mootools and jQuery concurrently in joomla ?
Thank you in advance for your help!
Reading your code, I see this:
but it should look like this:
Now, here’s why:
Javascript is interpreted in the order it comes to the page. The page is being told to use jQuery.noConflict() and the jQuery datatable, before it knows what those things are.