Bug Tracker

Modify

Ticket #4950 (closed feature: patchwelcome)

Opened 4 years ago

Last modified 3 years ago

.click(function(){} on option error in IE

Reported by: Dale Owned by:
Priority: major Milestone: 1.4
Component: event Version: 1.3.2
Keywords: Cc:
Blocking: Blocked by:

Description

I found an internet explorer bug when performing an onclick function on an <option>

I have code like thus:

var $dropSelectMainCurrent = $('<select></select>').attr('id','dropSelectMainListCurrent'); var $mainListItems2 = $('.linksNameMain_0'); var $mainSelectListValues2 = new Array(); var $mainSelectList2 = new Array(); for (var i=0; i<$mainListItems2.length;i++) {

$mainSelectListValues2[i] = $($mainListItems2[i]).attr("value"); $mainSelectList2[i] = $('<option></option>') .text($mainSelectListValues2[i]) .attr('id','mainLinkOption') .click(function() {

var $thisOptionText2 = $(this).text(); $('.'+$currentDropMenu).html($thisOptionText2+' Drop'); $('#dropSelectChosen').html($thisOptionText2+' Drop'); return false;

});

$dropSelectMainCurrent.append($mainSelectList2[i]);

} $('#dropSelectMain').append($dropSelectMainCurrent).show();

The click function on this item to be appended works perfectly in Firefox but does not work in IE.

Change History

comment:1 Changed 3 years ago by dmethvin

  • Type changed from bug to feature
  • Component changed from unfiled to event

Unfortunately, IE doesn't support click events on option elements.

 http://msdn.microsoft.com/en-us/library/ms535877%28VS.85%29.aspx

The W3C says it should though:

 http://www.w3.org/TR/html401/interact/forms.html#h-17.6

I'll change this to a feature request.

comment:2 Changed 3 years ago by dmethvin

See also dup #4780 which proposes implementing by hooking the select event and divining how options change.

comment:3 Changed 3 years ago by dmethvin

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

The fix proposed in #4780 seems like it would require too much code to be practical in core, given this is not a critical bug. Anyone with an idea for a succinct patch, please reopen the ticket and we can discuss. All other lurkers, feel free to register here on Trac and vote for this bug using the links at the top of the page.

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.