![]() |
where to put javascript - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: where to put javascript (/showthread.php?tid=12786) Pages:
1
2
|
where to put javascript - El Forum - 10-31-2008 [eluser]syntaxerror[/eluser] hi, i have a javascript menu bar it has 1 folder (lib folder) and five files (menu.php - this is the index, demo.css, demo.js, mootools.js, .project). it is working on standalone. my question is how and where can i save this files in code igniter to work. i copy/paste it in the view and change the controller function index() to $this->load->view('menu',$data). but the effects didnt work, it should slide down, but what it did is just a link my menu.php script is Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> where to put javascript - El Forum - 10-31-2008 [eluser]quince[/eluser] Hi, i have almost the same problem, i'm using jquery scripts for the menu and ajax but they don't work, it seems that jquery files are not loaded, if i put jquery files in the view directory, what is the path i have to use in an view file which is in the view directory ?what file jquery files are relative to? thanks where to put javascript - El Forum - 10-31-2008 [eluser]syntaxerror[/eluser] i think javascript is disable in codeigniter because when i transfer the javascript outside the codeigniter (standalone script) it works. but in the codeigniter the animation doesnt works. can anyone please tell us how and why. thanks where to put javascript - El Forum - 10-31-2008 [eluser]Pascal Kriete[/eluser] Javascript and PHP are two completely independent entities. PHP is executed on the server side - javascript on the client side. One cannot 'disable' the other. Create a folder in your application root - let's call it javascript. Plop your javascript source files in there. Make sure you can access it. Link to it. Done. Code: <head><title>Test</title></head> Let me know if you need a more thorough example. where to put javascript - El Forum - 10-31-2008 [eluser]Bramme[/eluser] I can't believe how many people have problems understanding this. This must've come up a 1000 times allready. where to put javascript - El Forum - 10-31-2008 [eluser]wr5aw[/eluser] [quote author="Bramme" date="1225493203"]I can't believe how many people have problems understanding this. This must've come up a 1000 times allready.[/quote] Here's a reply that actually has value: When using Php, relative file names in html (those without a full url), such as css and javascript are relative to the location of your index.php file. Suppose your index.php in is /myfolder/. Then if you want 'js/myjs.js' in your html, myjs.js needs to be in /myfolder/js/. Took about 30 seconds to respond. Didn't feel a thing. :coolhmm: where to put javascript - El Forum - 10-31-2008 [eluser]Nick Husher[/eluser] I'm fairly sure that relative URLs are relative to the URI of the request, not the location of the index.php file. where to put javascript - El Forum - 10-31-2008 [eluser]wr5aw[/eluser] [quote author="Nick Husher" date="1225501361"]I'm fairly sure that relative URLs are relative to the URI of the request, not the location of the index.php file.[/quote] You're right. I wasn't considering a path in the URI. Brain fart yanno. :-) where to put javascript - El Forum - 11-02-2008 [eluser]syntaxerror[/eluser] still no success. i tried all your suggestions and its just keep doing the same thing. my javascript is not working in CI. i will attach the javascipt file, you can test it outside the CI, and test it inside CI. and please tell me whats your result. thanks where to put javascript - El Forum - 11-02-2008 [eluser]henrihnr[/eluser] Please do as inparo promote... and invoke your script using url helper Code: src="<?php echo base_url(); ?>js/mootools.js" |