0 votar contra favorita
I've searched everywhere but I couldn't find a step-by-step on how to use JQuery on Joomla 3.8. I'm creating a module and I'd like to use JQuery. So here what I have done:
downloaded jquery-3.3.1.js and put in /modules/mod_mymodule/js
Reading Joomla documentation, I added these lines on my /modules/mod_mymodule/mod_mymodule.php file:
JHtml::script(JURI::base() . 'js/jquery-3.3.1.js');
Jhtml::_('jquery.framework');
Jhtml::_('jquery.ui');
At the bottom of my default.php file I added this:
<?php
$document = JFactory::getDocument();
$document->addScriptDeclaration('
window.event("domready", function() {
alert("An inline JavaScript Declaration");
});
');
?>
It was supposed to show an alert window when the page is loaded but it does not work. So what can I be doing wrong here?
You are using wrong mootools method replace window.event to window.addEvent
$document = JFactory::getDocument();
$document->addScriptDeclaration('
window.addEvent("domready", function() {
alert("An inline JavaScript Declaration");
});
');