问题
We want to implement HighCharts in our custom Joomla module. Since it's a Javascript library, do we attach it to the view as a reference to the script files? I've also read about a PHP wrapper for HighCharts. Is it advisable to use it instead of the direct Javascript library?
回答1:
To embed Javascript files into a Joomla module, you need to use the following code:
$document =& JFactory::getDocument();
$document->addScript(JURI::root() . "modules/mod_your_module/file.js");
$document->addScript(JURI::root() . "modules/mod_your_module/file2.js");
...
If you need to write custom Javascript, then you will need to write it like so:
$js = 'alert("alert message");';
$document->addScriptDeclaration($js);
Hope this helps.
来源:https://stackoverflow.com/questions/12770484/seeking-guidance-on-implementing-highcharts-in-joomla