Author Topic: javascript in codeigniter is not workign  (Read 7807 times)

0 Members and 1 Guest are viewing this topic.

Offline homer.favenirTopic starter

  • Enthusiast
  • Posts: 271
  • Gender: Male
    • View Profile
javascript in codeigniter is not workign
« on: October 31, 2008, 04:51:46 AM »
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: [Select]
<!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>

Offline wildteen88

  • Guru
  • 'Insane!'
  • *
  • Posts: 12,021
  • Gender: Male
    • View Profile
Re: javascript in codeigniter is not workign
« Reply #1 on: October 31, 2008, 06:04:04 PM »
You should place all your static files (css, js, images etc) where your index.php file is.

Offline Liquid Fire

  • Devotee
  • Posts: 858
    • View Profile
Re: javascript in codeigniter is not workign
« Reply #2 on: November 01, 2008, 08:54:26 AM »
You should place all your static files (css, js, images etc) where your index.php file is.
That is a pretty ugly structure to have your index.php, css, images, and js is the same folder without be able to break it up.

Offline wildteen88

  • Guru
  • 'Insane!'
  • *
  • Posts: 12,021
  • Gender: Male
    • View Profile
Re: javascript in codeigniter is not workign
« Reply #3 on: November 01, 2008, 10:23:25 AM »
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

Code: [Select]
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
Code: [Select]
<link rel="stylesheet" type="text/css" href="<?php echo base_url().'static/style.css'?>" />

Offline Liquid Fire

  • Devotee
  • Posts: 858
    • View Profile
Re: javascript in codeigniter is not workign
« Reply #4 on: November 01, 2008, 01:16:57 PM »
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

Code: [Select]
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
Code: [Select]
<link rel="stylesheet" type="text/css" href="<?php echo base_url().'static/style.css'?>" />


Ah... I thought tou mean something like
Code: [Select]
My CodeIgnitor App
|
+-- System/
|
+-- Application/
|
+- jquery.js
+- site.css
+-etc...
+- index.php
« Last Edit: November 01, 2008, 01:17:42 PM by Liquid Fire »

Offline wildteen88

  • Guru
  • 'Insane!'
  • *
  • Posts: 12,021
  • Gender: Male
    • View Profile
Re: javascript in codeigniter is not workign
« Reply #5 on: November 01, 2008, 01:19:38 PM »
Nope

Offline homer.favenirTopic starter

  • Enthusiast
  • Posts: 271
  • Gender: Male
    • View Profile
Re: javascript in codeigniter is not workign
« Reply #6 on: November 03, 2008, 09:22:15 PM »
i got it!
i copy/paste the javascript directory after the base url.
Code: [Select]
C:\xampp\htdocs\DSValidator\javascript
and change my script to
Code: [Select]
<!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.