Forums

Order of script inclusion

Minnie Mouse 10 Oct, 2012
hi,
i am trying to include my own datepicker into a multipart form. I am trying to only use jquery on my site. i am trying to include a very simple datepicker plugin. i have the initializing code in a loadjs element on my second page. I have tried every which way to include the plugin script and it comes out under the loadjs and triggers an error (of course).

i tried adding it to a custom code element and no luck.

I have tried loading it above the head declaration on my index page. then it comes out above the jquery declaration in the header.

i have tried adding it in a module that inserts into the head declaration (mod_jt_custom) and it comes out under the loadjs script.

This is really frustrating. where should i be putting this so it comes out above the loadjs.

<script type="text/javascript" src="<?php echo JURI::base(); ?>templates/MYTEMP/js/datepicker/javascript/zebra_datepicker.js"></script>
<link rel="stylesheet" href="<?php echo JURI::base(); ?>templates/MYTEMP/js/datepicker/css/zebra_datepicker.css" type="text/css">

thanks! Liz
Max_admin 11 Oct, 2012
Hi Liz,

Try adding those lines to your template directly before the header loading line.

Regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
GreyHead 11 Oct, 2012
Hi Liz,

Alternatively, rather than add the lines to the template and have them load on every page use the Joomla! code to load them into the header from your ChronoForm.

Try this in a Custom Code action (or in the Load JS action if you prefer to keep them together).
<?php
$doc =& JFactory::getDocument();
$doc->addScript(JURI::base().'templates/MYTEMP/js/datepicker/javascript/zebra_datepicker.js');
$doc->addStyleSheet(JURI::base().'templates/MYTEMP/js/datepicker/css/zebra_datepicker.css');
?>

Joomla! loads files like this before snippet declarations.

The only potential problem is managing the order in which JQuery loads to make sure that is it before the datapicker.js file.

Unfortunately, unlike Wordpress, Joomla! doesn't have any facility to manage dependencies automatically.

Bob

PS Much as I like JQuery - choosing to use only JQuery on a Joomla! site is a kind of masochistic choice :-)
This topic is locked and no more replies can be posted.