I am a newbie in codeigniter. I want to load jquery on every page. I know we have to use autoload.php. But inside it there is section where static contents like js or css can be included. How to do this? I created another index like this
$autoload['static'] = array(JS_LIBS_PATH.'/jq.js');
But obviously nothing happened. That constant has been defined in config,php. Using same constant I could put jq on a page, but what about autoload ?
I can think of several elaborate solutions but I really think that javascript is presentation-level and shouldn’t be in your autoload, models, controllers, etc.
You can just use a master view file of some kind with your
<head>and basic HTML requirements:Then just load views like this:
Of course this is just one solution out of millions, but the idea of Codeigniter “autoloading” CSS and Javascript makes no sense, you have to “load” it yourself in one way or another – how you do it is completely up to you.