Bug Tracker

Opened 13 years ago

Closed 13 years ago

#6702 closed bug (duplicate)

live change event handler on select element does not work

Reported by: fastfasterfastest Owned by:
Priority: Milestone: 1.4.3
Component: event Version: 1.4.2
Keywords: live change select Cc:
Blocked by: Blocking:

Description

A live change event handler attached to a select element does not work *if* a live click event handler has been attached to an anchor element first, see complete sample below. I.e., if the event handlers are attached in the following manner, then the change event handler on the select element does not work: $(function() {

$('a').live('click', function() {

alert('live click'); return false;

}); $('select').live('change', function() {

alert('live change'); return false;

});

});

However, if one changes the order in which the event handlers are attached (first attach the change event handler to the select element, then the click handler to the anchor element), it does work. The following works: $(function() {

$('select').live('change', function() {

alert('live change'); return false;

}); $('a').live('click', function() {

alert('live click'); return false;

});

});

Below follows complete sample:

<html xmlns="http://www.w3.org/1999/xhtml"> <head> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text/javascript"></script> </head>

<body>

<select><option value="0">Select 0</option><option value="1">Select 1</option></select> <br/> <a href="#">Click</a>

<script type="text/javascript"> $(function() {

$('a').live('click', function() {

alert('live click'); return false;

}); $('select').live('change', function() {

alert('live change'); return false;

});

}); </script>

</body> </html>

Change History (4)

comment:1 Changed 13 years ago by fastfasterfastest

comment:2 Changed 13 years ago by fastfasterfastest

I just noticed #6505, http://dev.jquery.com/ticket/6505, which appears to be the same issue.

comment:3 Changed 13 years ago by Psihius

Wanted to add that this works in 1.4.1 and is broken in 1.4.2

comment:4 Changed 13 years ago by snover

Resolution: duplicate
Status: newclosed

Duplicate of #6505.

Note: See TracTickets for help on using tickets.