Is it possible when creating a view in Codeigniter to use a command to register an external Javascript file to be included in the <head> when the final output is written?
I have a main view which contains many smaller sub-views (sidebar, adverts, other controls, etc). inside one or more of these smaller views i want to incorporate some javascript functionality. To keep things modular i would like to ‘include’ that Javascript inside the smaller sub-views (without actually writing it to the html page at that sub-view’s position (i want it in the head)). Is this possible?
I ended up overiding and implementing my own
Outputclass. (Placed in the ‘application/core/’ folder)I added the tags
{VIEW_SPECIFIC_JAVASCRIPT}and{VIEW_SPECIFIC_CSS}into my<head>view at the appropriate places.Then i can add javascript and css into the
<head>from any view in my application by using the following methods inside the views:Simple.