Here is my sample code:
public function index()
{
$this->load->view('templates/base_header');
$this->load->view('templates/login');
$this->load->view('templates/base_footer_JS');
echo "<script src='".base_url()."/lib/scripts/login.js'></script>";
}
JavaScript is working but jQuery does not defined.
Codeigniter has a javascript class: http://codeigniter.com/user_guide/libraries/javascript.html
You would load the jquery library through:
$this->load->library('jquery');
Then you can paste this into your head section of your view:
<?php echo $library_src;?>
<?php echo $script_head;?>
For additional javascript files, I typically create a resource folder in my application folder, then use the base_url function to link to the files like:
<script src="<?php echo base_url('resources/name-of-js-file.js');?>" type="text/javascript"