Return false will break you

Posted on

I just had this issue (and I’ve had it before) with jQuery live bindings not getting triggered. I checked and double checked. The element was in fact bound to the event. But when I clicked on it, nothing would happen, and no errors were thrown. I spent a while telling Google about it but teh Googs had nothing to say. After a few hours I realized what I had done.

So what was the problem? return false. There was another event bound to the element which had a return false at the end, thus preventing subsequent events from firing. Once I removed it (and replaced it with event.preventDefault) everything worked as expected. Moral of the story is to be judicious when using return false.

For more information read jQuery Events: Stop (Mis)Using Return False. Also, there was a really helpful post/discussion over on StackOverflow regarding when and how to use returnproperly. Check it out.