[eluser]LuckyFella73[/eluser]
If you need a solution to load javascripts depending
on the page that is loaded I can tell you what I do
(there may be better ways of course)
I have a config file where I define all needed javascripts - for example:
Code:
$this->js_formscript_news ='<scri+pt type="text/java+scri+pt" src="'.base_url().'js/formscripts_news.js"></scri+pt>';
$this->js_formscript_press ='<scri+pt type="text/java+scri+pt" src="'.base_url().'js/formscripts_press.js"></scri+pt>';
// and so on
In the contructor of my controller I load the config file
Code:
$this->load->file('system/application/config/config_admin.php', true); // for example
In the different functions (before calling the view files I
set the needed js in case I need one or more like this:
Code:
$data['js_import'] = array ($this->js_formscript_news,$this->js_formscript_press);
And at last in view file (header part of course) I have this:
Code:
<?php
if ( isset( $js_import ) AND count( $js_import ) > 0 )
{
foreach ($js_import AS $js_data)
{
echo $js_data;
}
}
?>
If somebody has a better solution I would be really interested in!