Welcome Guest, Not a member yet? Register   Sign In
Javascript Nightmare
#11

[eluser]Lone[/eluser]
Less the one '/' before assets as your base_url should have a trailing slash.

Quote:<?php echo base_url(); ?>assets/css/style.css

Sorry michael Tongue
#12

[eluser]psdtocode[/eluser]
It doesn't seem to be working. The ouptut cuts off right before the code I inserted: <?php echo base_path(); ?>. I tried both short tags and normal syntax, even though both should work. No PHP errors are being outputted (though I have yet to see one, not sure how to turn them on ATM).

Here is my code (don't want to go through trying to post HTML again):
http://www.grabup.com/uploads/f093dd5edc...946b8f.png

Here is the source it outputs:
http://www.grabup.com/uploads/0c4be0bef9...33c4cb.png
#13

[eluser]Crimp[/eluser]
Don't forget to:

Code:
$this->load->helper('url');

I tend to put this in autoload 'cause it's so handy.
#14

[eluser]psdtocode[/eluser]
Ah, okay, thanks. I didn't know base_url() was part of the url helper. I also figured it that was true, then it would show an error.

I finally got it included, however, now the JS itself isn't working (not sure if it's my code or if prototype still isn't being included even though the path works and I get no error):

$('link').onclick = function() {
alert('hi');
}

<a href="#" id="link">asdf</a>
#15

[eluser]Michael Wales[/eluser]
Caught me Sad
#16

[eluser]Michael Wales[/eluser]
Code:
$(’link’).onclick = function() {
alert(’hi’);
}

<a href="#" id="link">asdf</a>

Isn't Javascript case sensitive? Plus, just doing a quick review of the Prototype API documentation (I'm a jQuery user, myself) - this seems to be more appropriate:

Code:
$('link').observe('click', alertLink);
function alertLink(event) {
  alert('Hi');
}

or even:
Code:
$('link').observe('click', function(event) {
  alert('Hi');
});
[/code]
#17

[eluser]psdtocode[/eluser]
Didn't work. I'm in Minnesota just on my mac, so I'll play around with it on my PC when I have more time. Smile
#18

[eluser]adwin[/eluser]
I did like this

I created a directory named public/

Code:
/- root
  -system\
   -application
   -library
   ... etc (code igniter default)
  -public\
    - css\
    - img\
    - js\

and i put this on my view (header)
Code:
<l i n k href="&lt;?=$this->config->item('base_url');?&gt;public/css/mycss.css" rel="stylesheet" type="text/css" />

&lt; script type="text/javascript" src="&lt;?=$this-&gt;config->item('base_url');?&gt;public/js/jquery-1.2.6.pack.js">
#19

[eluser]@li[/eluser]
Install firebug and run the page in firefox to see exactly what javascript error you get




Theme © iAndrew 2016 - Forum software by © MyBB