Tuesday, July 3, 2012

Adding javascript file in Joomla view file

If you want to use a javascript file in a view file (i.e. myComponent/views/student/tmpl/default.php) you will not be able to inlcude using

<script type="text/javascript" src="" />

As you will see it won't load the file and hence won't work. So to include a file you will need to use something like this:


$document = &JFactory::getDocument();
$document->addScript( 'myfilepath/myjsfile.js' );

No comments:

Post a Comment