Ticket #5959 (closed bug: fixed)
Change event for Select element getting fired on click (occuring in 1.4.1)
| Reported by: | noelmccrory | Owned by: | brandon |
|---|---|---|---|
| Priority: | major | Milestone: | 1.4.2 |
| Component: | event | Version: | 1.4.1 |
| Keywords: | Cc: | ||
| Blocking: | Blocked by: |
Description
See the following example:
<script type="text/javascript"> $(document).ready(function(){
$('#dropDownList1').bind('change',function(){
alert("changed"); });
$('#btnChange').click(function(){
$('#dropDownList1')[0].selectedIndex = 0; Note: Setting the val() of the select list instead does not make a difference to the outcome of this test
});
}); </script>
<select id="dropDownList1">
<option value="0">0</option> <option value="1">1</option> <option value="2">2</option>
</select> <a href="#" id="btnChange">Change</a>
Execute the following steps:
- Choose "2" from the select list.
- Click the "Change" link.
- Click the select list.
When you click the select list in the 3rd step, an alert containing "changed" appears. This does not appear in version 1.3.2.
Attachments
Change History
comment:1 Changed 3 years ago by noelmccrory
I should have mentioned that this problem is occuring in both IE 7 and 8. It does not occur in Firefox 3.5.7 though.
comment:2 Changed 3 years ago by simshaun
Would just like to say its happening for me as well using 1.4.1, under a slightly different circumstance. (Happens under IE6, IE7, and IE8)
I've got a "Choose Photo Gallery" dropdown with several options. The dropdown has an onChange event binded to it; When the dropdown changes, the window.location is set to whatever the selected option's value is. In other words, the page reloads with a different query string whenever an option is chosen. When the page loads, an option is selected by default based on a parameter in the query string (handled by PHP, not JavaScript).
When an option that is NOT the first option is selected by default, anytime I click the dropdown in IE it fires the onChange event, even though I did not choose an option.
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

