Bug Tracker

Modify

Ticket #5959 (closed bug: fixed)

Opened 3 years ago

Last modified 3 years ago

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:

  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

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

Change History

Changed 3 years ago by noelmccrory

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.

comment:3 Changed 3 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 3 years ago by snover

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

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.