views:

75

answers:

3

Hi,

I have some code on some of my links

<a class="nav_bu" onclick="switchType('all'); return false;" href="#">

when I click on them, I get fowarded to mydomain.com/# (404 error..).

How can I get the function activated, rather then the href link.

P.S. I have mod_rewrite running, is this screwing things up? Here are the rules that effect the root directory:

RewriteRule ^home/$ home.php [L]
RewriteRule ^inbox/$ inbox/inbox.php [L]
+16  A: 

I think you have an error in the switchType('all') function. That is why the browser does not get to return false; and uses the default action to redirect you to href.

Eldar Djafarov
I agree with you.
Noon Silk
Agree with this. I never had problems with the #.
OregonGhost
Agreed, the shown code is just fine, so there has to be an error in the function. Show Javascript errors: In IE enable "Display a notification...", in Firefox open the error console.
Guffa
+2  A: 

use button instead of link

Kamarey
Agreed. Buttons should be buttons, links should be links.
James Wiseman
There is a point to that... However there is still an error in the functon that is called so it doesn't fix the root of the problem.
Guffa
right, but there is no more problem with '#', and you don't spend hours to find a bug in mod_rewrite rules:)
Kamarey
@Guffa: by the way, your answer on this question http://stackoverflow.com/questions/1133581/is-23-148-855-308-184-500-a-magic-number-or-sheer-chance is amazing!
Kamarey
A: 

First of all, you state, based on your tags, that you are using jQuery. Why would you be using inline javascript listeners then?

Try this:

$(function() {
    $('.nav_bu').click(function() {
        switchType($(this).attr('rel'));
        return false;
    });
});

If this is your HTML:

<a class="nav_bu" rel="all" href="#">Blah Blah</a>

But, yeah... like people are saying, you probably have a problem with your switchType function. Run the site in Firefox with Firebug installed and it should tell your right where you problem is.

KyleFarris