views:

330

answers:

1

I have the following snippet which works as expected:

<a href="http://google.com" onclick="return false;">Will go to google</a>

Clicking on the href does not take me to google.

But... if I include JQuery 1.4 and wire up a live click event to anything on the page (whether it exists or does not) this unrelated event handler stops working as expected in IE (and continues to work in firefox and chrome). Return false is ignored and instead clicking on the link takes you to google.

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js" type="text/javascript"></script>
<script type='text/javascript'>
          //<![CDATA[
    $(document).ready(function() {
         $(".not-here").live("click", function() {alert("hi"); return false; });
    });
          //]]>
 </script>

Whats going on? Have I come across a bug in the JQuery 1.4 release.

+3  A: 

Yes this is a bug in JQuery 1.4 Release. It affects anyone using the live events.

It was patched by John on the 24th of Jan 2010. It has been fixed in JQuery 1.4.1 which was released on the 26th of Jan 2010.

See: http://dev.jquery.com/ticket/5835

Sam Saffron
+1 - good catch
Russ Cam
That bug report has nothing to do with this bug. Did I miss something?
Crescent Fresh
@Crescent, yerp I linked to a different bug, corrected
Sam Saffron