As title said, I\'m trying to figure out how to use javascript and jquery libraries on CI.
Following instruction in the docs, I load the library in my controller:
As we know on the user guide, first, it was an experimental but working. Thr first step is open your config file under application/config/config.php .
Put the following line :
// path to JS directory you want to use, I recommended to put the .js file under 'root app/js/yourfile.js'
$config['javascript_location'] = 'js/yourfile.js';
Second step is open your controller, within constructor method, put the following code :
// Load javascript class
$this->load->library('javascript');
$this->load->library('javascript/jquery'); // if u want to use jquery
Then, still in controller file within index method :
$data['library_src'] = $this->jquery->script(); // Because I refer to use jquery I don't test to use $this->javascript->script().
Then open your view file and put the following code within tag head :
That way is working for me, let's try it.