Skip to main content

Bug Tracker

Side navigation

#6702 closed bug (duplicate)

Opened June 22, 2010 02:35AM UTC

Closed September 22, 2010 10:27PM UTC

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>

Attachments (0)
Change History (4)

Changed June 22, 2010 07:49PM UTC by fastfasterfastest comment:1

Changed June 25, 2010 02:41AM UTC by fastfasterfastest comment:2

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

Changed July 02, 2010 12:15PM UTC by Psihius comment:3

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

Changed September 22, 2010 10:27PM UTC by snover comment:4

resolution: → duplicate
status: newclosed

Duplicate of #6505.