Bug Tracker

Opened 10 years ago

Closed 9 years ago

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

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:

  1. Choose "2" from the select list.
  2. Click the "Change" link.
  3. 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 (1)

test.zip (23.5 KB) - added by noelmccrory 10 years ago.

Download all attachments as: .zip

Change History (5)

Changed 10 years ago by noelmccrory

Attachment: test.zip added

comment:1 Changed 10 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 10 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.

comment:3 Changed 10 years ago by noelmccrory

This appears to have been fixed in 1.4.2.

Nothing in the release notes about it, but thanks anyways!

comment:4 Changed 9 years ago by snover

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.