Bug Tracker

Modify

Ticket #6702 (closed bug: duplicate)

Opened 3 years ago

Last modified 3 years ago

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:
Blocking: Blocked by:

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

comment:1 Changed 3 years ago by fastfasterfastest

comment:2 Changed 3 years ago by fastfasterfastest

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

comment:3 Changed 3 years ago by Psihius

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

comment:4 Changed 3 years ago by snover

  • Status changed from new to closed
  • Resolution set to duplicate

Duplicate of #6505.

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.