views:

239

answers:

1

Hello,

I am attempting to prevent default anchor behavior in Safari using the jQuery library. Unfortunately, the standard techniques of returning false or using event.preventDefault() do not seem to be working in Safari.

Could anyone help me with this issue?

The code I'm working with is like this:

$('#main .green-tabs a').live("click",function(event){
                    $('.green-tabs a').removeClass('active');
                    $(this).addClass('active');
                    event.preventDefault();
                    var that = this;
                    return LolPage(event,that);});
A: 

Having the handler return false works for me in Safari and FF and Chrome. See my test page here: http://gutfullofbeer.net/bind.html and it also works if I have the handlers call "preventDefault" instead of just returning false.

The "LolPage" function is left out of your question, and I have to wonder whether that might be of great importance here.

Pointy
Hi Pointy, that function always returns false and does not error out. I should also mention that this application lives in the facebook environment which I think might be the culprit for some strange reason. I am going to run a few tests in that environment and will post my results here.
Macy Abbey
OK, well good luck! Mysterious problems like this are always interesting.
Pointy