Search code examples
javascriptjoomlajoomla-extensions

How to add javascript to joomla module?


Hi I have problem with adding javascript into a joomla module..I've found some solution, but it's not working..

$document = &JFactory::getDocument();
$document->addScript("/career.js");    

These two lines I have in my module, but the script isn't in rendered site.. The file is in root of my web (for test purposes only).

Thanks for your help


Solution

  • Ouch..The main problem is, that I am loading the page containing custom module with javascript is loaded via ajax..And all the plugins seems to be adding the js code into head and I only replace some elements into body of my page. exist some solution to this problem?I know I can have all the js logic into one file, but I am not sure it is good way. Is somehow possible to include js directly to module?So that the script tag will be within my document body and correctly included (i am not sure the code will be fired??)

    Thanks