div onclick |
[eluser]frietkot[/eluser]
Hi, I have a div and I want to use onClick on it. Normally it just works fine, but not with codeigniter. Code: onClick='window. location.href="<?=anchor('test', 'test')?>;"' It does nothing at all. Any ideas?
[eluser]GSV Sleeper Service[/eluser]
is that your example code? if so, it does nothing because there's no onclick code there! really you should be using jquery or prototype.js and using unobtrusive javascript. I have used clickable divs a lot in codeigniter and never had any problems [edit] your example code changed.
[eluser]frietkot[/eluser]
I think it's a problem with the anchor helper Without it it just works, with it not. (btw I put an space between window and location because the forum didn't show the snippet without the space)
[eluser]GSV Sleeper Service[/eluser]
ah, yes. the anchor helper will create an href tag. so your code would look like Code: onClick='window. location.href="<a href="test">test</a>"'
[eluser]jcopling[/eluser]
Given the code example that you have provided, you would be setting the URL to something like: http://<a href="test">test</a> Which is not the desired effect. You would want to product something like: http://yourdomain.com/test You can achieve this with the following code: Code: onClick="window .location .href='<?= base_url();?>/test'" |
Welcome Guest, Not a member yet? Register Sign In |