Opened 13 years ago
Closed 13 years ago
#6059 closed bug (fixed)
Live don't work correctly on class selectors since 1.4
Reported by: | Quentin | Owned by: | |
---|---|---|---|
Priority: | Milestone: | 1.4.2 | |
Component: | event | Version: | 1.4.1 |
Keywords: | live | Cc: | |
Blocked by: | Blocking: |
Description
I have the situation. I handle events using live() function and class selector. At handler I change class of element. So this element's events now will be handled by another live function. In JQuery version 1.3.2 this works, but in version 1.4 and above - do not. Sorry for my bad English, here is a simple example:
<html> <head> <script src="jquery-1.3.2.min.js" type="text/javascript"></script> <script type="text/javascript">
$(document).ready(function() {
$("div[class='bla1']").live("click", function(e) {
alert($(this).attr('class')); $(this).removeClass('bla1'); $(this).addClass('bla2');
});
$("div[class='bla2']").live("click", function(e) {
alert($(this).attr('class')); $(this).removeClass('bla2'); $(this).addClass('bla1');
});
});
</script> </head> <body>
<div class='bla1'>Click me!</div>
</body> </html>
All works fine in JQuery 1.3.2! When I click on a div again and again, I see messages: "bla1", "bla2", "bla1" and so on. But only first click on a div is handled, if I change used version of JQuery to 1.4 or 1.4.1. So I see only one message "bla1", and other clicks on a div do nothing. I think this is a bug. Fix it, please.
Change History (2)
comment:1 Changed 13 years ago by
comment:2 Changed 13 years ago by
Resolution: | → fixed |
---|---|
Status: | new → closed |
Version: | 1.4 → 1.4.1 |
I copied your exact test page and it's working correctly in the latest nightlies.
Oh, I forgot! I have tested this example in three browsers - IE 6, FF 3.5.7 and Chrome 4. All three browsers show the same results - JQuery 1.3.2 works, and JQuery 1.4 - do not.