Welcome Guest, Not a member yet? Register   Sign In
where to put javascript
#1

[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">
&lt;html &gt;
&lt;head&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;
    &lt;link rel="stylesheet" href="demo.css" type="text/css" /&gt;
    [removed][removed]
    [removed][removed]
    &lt;title&gt;MouseEnter Demo&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
    <div id="myElement">
    </div>
    
    <div id="myOtherElement">
        <span><strong>Menu</strong></span>
        <div>
            <a href="#">Client 1</a>
            <a href="#">Client 2</a>
            <a href="#">Client 3</a>
        </div>
    </div>
&lt;/body&gt;
&lt;/html&gt;
#2

[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
#3

[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
#4

[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:
&lt;head&gt;&lt;title>Test&lt;/title&gt;&lt;/head>
&lt;script src="http://example.com/javascript/javascriptfile.js" type="text/javascript" charset="utf-8"&lt;&gt;/script&gt;
&lt;/head&gt;

Let me know if you need a more thorough example.
#5

[eluser]Bramme[/eluser]
I can't believe how many people have problems understanding this. This must've come up a 1000 times allready.
#6

[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:
#7

[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.
#8

[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. :-)
#9

[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
#10

[eluser]henrihnr[/eluser]
Please do as inparo promote...

and invoke your script using url helper

Code:
src="&lt;?php echo base_url(); ?&gt;js/mootools.js"




Theme © iAndrew 2016 - Forum software by © MyBB