Skip to main content

Bug Tracker

Side navigation

#1641 closed bug (wontfix)

Opened September 17, 2007 01:33PM UTC

Closed March 25, 2010 02:47AM UTC

Last modified March 15, 2012 12:23AM UTC

append() in IE does not properly handle Options

Reported by: scubstev834 Owned by:
Priority: minor Milestone: 1.2.3
Component: core Version: 1.2
Keywords: append IE Option select Cc:
Blocked by: Blocking:
Description

In IE (Internet Explorer), if you append an anonymous Option the text is not rendered and even though the option is now selectable in the select box (multi-select or singular), there is no value associated. The only way around this is to append the Option as text instead of creating the DOM element.

What I did:

$("#myselectbox").append( new Option( "stuff","stuff") );

What works:

$("#myselectbox").append( "<option value='stuff'>stuff</option>" );

This is not a problem in Mozilla Firefox.

Attachments (0)
Change History (7)

Changed December 04, 2007 09:07AM UTC by davidserduke comment:1

milestone: 1.2.11.2.2
resolution: → wontfix
status: newclosed

As noted by the author this is a problem with IE (works in Safari, FF, and Opera). Attempt the following code in IE:

document.getElementByTagName("select")[0].appendChild(new Option("stuff", "stuff"));

and it fails as well. IE seems to only want to use Options created with new for the Select.add() type functions.

At this point it doesn't make sense to me to add a bunch of code for this specific purpose when the author has already noted a perfectly valid workaround. So I'm going to close this bug as wontfix (although I try to avoid doing that). If someone thinks this is a bigger issue than I do, please feel free to reopen the bug with your explaination of why you think this should be fixed and it will be considered.

Changed January 17, 2008 02:16PM UTC by shieldo comment:2

resolution: wontfix
status: closedreopened

I don't think this should be a wontfix. A recent attempted upgrade to 1.2.2 broke previously working code for me for this reason (it worked in 1.2.1). The documentation for append refers to append(content), and 'content' should include jQuery objects (such as a set of options). A main advantage of a JS library is that is should account for browser quirks so the developer can use them without worrying too much that the abstraction will leak. append(content) should imho do exactly what it says on the tin, in all cases. The workaround is too clumsy for dealing succinctly with multiple options.

Changed January 18, 2008 03:38AM UTC by davidserduke comment:3

It was working in 1.2.1 and stopped in 1.2.2? Then I suspect it has nothing to do with this bug since this bug was never fixed. Might it be related to the clone() bug in #2184?

append() should correctly handle a set of jQuery objects that are options I agree. If it doesn't it is a different bug. Please feel free to open a new ticket for that specifically although I suspect it will be fixed when #2184 is.

Changed January 24, 2008 08:03PM UTC by shieldo comment:4

Thanks so much for that hint, it seems it was indeed related to the bug in #2184. I applied the patch in [4513] and all is well. So the status of this bug should be reverted.

Changed January 24, 2008 10:02PM UTC by davidserduke comment:5

milestone: 1.2.21.2.3
resolution: → wontfix
status: reopenedclosed

Thanks for getting back. :)

Putting status back to won't fix for the reasons described in the first comment.

Changed March 23, 2010 07:58PM UTC by jmalin comment:6

resolution: wontfix
status: closedreopened

I just spent time debugging why my Options didn't work in IE, then altering the code after I traced it back to this issue. This is absolutely a problem with how IE handles options, but it also should be fixed on the JQuery side. I love JQuery for the fact that it usually hides these kinds of details and lets me worry as a developer about functionality, not browser-compatibility issues. There is a workaround, but there shouldn't have to be one - JQuery should handle this behind the scenes, by checking to see if the browser is IE and appending options in HTML fashion in the way the workaround does.

Changed March 25, 2010 02:47AM UTC by dmethvin comment:7

resolution: → wontfix
status: reopenedclosed

If you review the history of this ticket you'll see that it's not something easily fixed by jQuery. I'll close the ticket again; if you can provide a patch please reopen and attach it.