Jump to content

javascript in codeigniter is not workign


homer.favenir

Recommended Posts

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

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <link rel="stylesheet" href="demo.css" type="text/css" />
    [removed][removed]
    [removed][removed]
    <title>MouseEnter Demo</title>
</head>
<body>
    <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>
</body>
</html>

You can place your images etc within separate folders too if you wish. The folders must be in the same directory as your index.php file though.

 

You should not be putting any static content anywhere in your application folder. I tend to setup my CI directory structure like so

 

My CodeIgnitor App
|
+-- System/
|
+-- Application/
|
+-- static/
|    |
|    +-- images/
|    |
|    +-- js/
|    |
|    +- style.css
+- index.php

 

When loading say style.css within my views for example I'd use

<link rel="stylesheet" type="text/css" href="<?php echo base_url().'static/style.css'; ?>" />

 

 

You can place your images etc within separate folders too if you wish. The folders must be in the same directory as your index.php file though.

 

You should not be putting any static content anywhere in your application folder. I tend to setup my CI directory structure like so

 

My CodeIgnitor App
|
+-- System/
|
+-- Application/
|
+-- static/
|    |
|    +-- images/
|    |
|    +-- js/
|    |
|    +- style.css
+- index.php

 

When loading say style.css within my views for example I'd use

<link rel="stylesheet" type="text/css" href="<?php echo base_url().'static/style.css'; ?>" />

 

 

 

Ah... I thought tou mean something like

My CodeIgnitor App
|
+-- System/
|
+-- Application/
|
+- jquery.js
+- site.css
+-etc...
+- index.php

i got it!

i copy/paste the javascript directory after the base url.

C:\xampp\htdocs\DSValidator\javascript

and change my script to

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html >
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <link rel="stylesheet" href="<?php echo base_url(); ?>javascript/demo.css" type="text/css" />
    [removed][removed]
    [removed][removed]
    <title>MouseEnter Demo</title>
</head>
<body>
    <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>
</body>
</html>

maybe this will help to anyone who have the same issue.

im sorry but i didnt made the [remove][/remove] tag.

its in the forum

 

thanks for all the help guys.

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.