Welcome Guest, Not a member yet? Register   Sign In
where to put js/jquery file how to use it in view files ?
#1

[eluser]sasori[/eluser]
Hi,

where do you usually or where is the perfect place to put the js/jquery files and how to invoke them or use them in CI 2.x.x ?

T.I.A
#2

[eluser]jblack199[/eluser]
How i do mine is in the root of the site I'll put an inc folder that has a css, images and js folder inside of them...

then in config.php I setup my base_url..

say for example it was on a localhost... localhost is my document_root but my project is in myapp so in config.php my base_url would be http://localhost/myapp/

then in my view, i'd include it like:

Code:
<scrpt type="text/javascript" src="&lt;?php echo base_url(); ?&gt;inc/js/jquery.js"></scrpt>]

which in the end would look like:

Code:
<scrpt type="text/javascript" src="http://localhost/myapp/inc/js/jquery.js"></scrpt>

note: had to remove the i from "script" otherwise it would remove it...

and if i am using a .htaccess to remove the index.php i'd ensure to include the inc folder in my allowable folders/files by:

Code:
RewriteCond $1 !^(index\.php|inc|robots\.txt)




Theme © iAndrew 2016 - Forum software by © MyBB