Skip to main content

Bug Tracker

Side navigation

#14426 closed bug (notabug)

Opened October 07, 2013 06:38PM UTC

Closed October 08, 2013 03:47PM UTC

Prepend and Each Doesn't Add Option to Select

Reported by: VajdaS@aptea.com Owned by: VajdaS@aptea.com
Priority: undecided Milestone: None
Component: unfiled Version: 1.10.2
Keywords: Cc:
Blocked by: Blocking:
Description

When I do this it works fine

$("[id*=FT_DDL_COMP0]").prepend(new Option("CHOOSE"));

$("[id*=FT_DDL_COMP0]")[0].options[0].selected = true

This combines the added options with the first existing one.

var cbos = $("[id*=FT_DDL_COMP]")

$.each(cbos, function (index, item) {

$(item[0]).prepend("<option value='' selected='selected'>CHOOSE</option>")

});

Attachments (0)
Change History (9)

Changed October 07, 2013 07:31PM UTC by rwaldron comment:1

owner: → VajdaS@aptea.com
status: newpending

Thanks for taking the time to contribute to the jQuery project! Please provide a complete reduced test case on jsFiddle to help us assess your ticket! Be sure to test against the "jQuery (edge)" version to ensure the issue still exists—you may need to change this to a specific version depending on the test case.

To get you started, use this boilerplate: http://jsfiddle.net/FrKyN/ Open the link and click to "Fork" (in the top menu) to begin.

Changed October 08, 2013 01:55PM UTC by anonymous comment:2

I added the code to jsfiddle but how do I save it? Also, I put in a radio button to show you my bug but the event didn't call the function I added.

Thanks. Steve

Changed October 08, 2013 02:44PM UTC by rwaldron comment:3

Replying to [comment:2 anonymous]:

I added the code to jsfiddle but how do I save it? Also, I put in a radio button to show you my bug but the event didn't call the function I added. Thanks. Steve

Click the "save" button

[[Image(http://gyazo.com/4b5ebd852696eb5a9a88b41e07a05797.png)]]

Changed October 08, 2013 03:00PM UTC by anonymous comment:4

OK. I created an account so I got the save button and saved it at

http://jsfiddle.net/VajdaS/5BnB3/ The radio buttons don't call my function and I don't know why and I can't debug. When you press the "good" radio button it calls the "good" code. Thanks. Steve

Changed October 08, 2013 03:07PM UTC by rwaldron comment:5

Thank you for providing the example on jsfiddle—can you please reduce the code to smallest possible unit that illustrates the bug? Thanks!

Changed October 08, 2013 03:23PM UTC by anonymous comment:6

OK. I made a real simple version at http://jsfiddle.net/VajdaS/7jqFd/

I've never used JSFiddle before. That was interesting. Thanks.

Changed October 08, 2013 03:29PM UTC by rwaldron comment:7

Replying to [comment:6 anonymous]:

OK. I made a real simple version at http://jsfiddle.net/VajdaS/7jqFd/ I've never used JSFiddle before. That was interesting. Thanks.

This has no version of jQuery selected?

It's still not clear to me what the issue is—can you clear define 1) the expected behaviour, and 2) the actual behaviour. Thanks

Changed October 08, 2013 03:39PM UTC by anonymous comment:8

OK I copied the previous after seting the ref to Jquery edge at

http://jsfiddle.net/VajdaS/tVTzn/. I added the CHOOSE option to both sets of drop downs but when I used the $each function it combined CHOOSE with the first existing option which is NONE.

Changed October 08, 2013 03:47PM UTC by rwaldron comment:9

resolution: → notabug
status: pendingclosed

This isn't a bug. item[0] refers to the first <option> child of the <select> and then you're prepending a new element to the beginning of the inside of that <option>. Take a look: http://jsfiddle.net/rwaldron/nCRVX/