Bug Tracker

Opened 9 years ago

Closed 9 years ago

Last modified 8 years ago

#9272 closed bug (invalid)

Select component and attr("selected")

Reported by: jeflbtest@… Owned by: jeflbtest@…
Priority: low Milestone: 1.next
Component: attributes Version: 1.6.1
Keywords: Cc:
Blocked by: Blocking:

Description

Hello,

Since jQuery 1.6 and 1.6.1, I'm trying to make working my intranet site, but it's hard to make it compatible with IE6 and IE>6 , OPERA.

My problem was to select dynamics values after charging data.

This was ok in 1.5.2 but not anyway since >1.6

I tried to use prop() function with :

$("#myList").find("option[value=\"" + myConf.code + "\"]").attr("selected",true) but not ok with IE6!

IE 6 must have "true" (double quoted) value instead of true ! This value "true" isn't compatible with OPERA

The only way I found, to make it compatible in my code, I added :

if(isIE6) {

valSelected = "true";

} else {

valSelected = "selected";

}

.....

$("#myList").find("option[value=\"" + myConf.code + "\"]").attr("selected",valSelected );

AND

mySeletedValue = $("#myList").find("option[selected=" + valSelected + "]").attr("value");

I hope this code could help somebody.

Jeff.

Change History (5)

comment:1 Changed 9 years ago by addyosmani

Component: unfiledattributes
Owner: set to jeflbtest@…
Priority: undecidedlow
Status: newpending

Thanks for taking the time to contribute to the jQuery project! Please provide a reduced test case on http://jsFiddle.net that reproduces the issue experienced to help us assess your ticket!

Additionally, test against the jQuery (edge) version to ensure the issue still exists.

comment:2 Changed 9 years ago by ajpiano

FWIW, the recommended way to set an option in a select to be selected if you know its value is to use the .val() method directly on the select itself. For instance:

$("#myList").val(myConf.code);

comment:3 in reply to:  2 Changed 9 years ago by jeflbtest@…

Status: pendingnew

Replying to ajpiano:

FWIW, the recommended way to set an option in a select to be selected if you know its value is to use the .val() method directly on the select itself. For instance:

$("#myList").val(myConf.code);

Thanks for this but it's what I done before 1.6.1, this code doesnt work in IE6.

It throws an IE6 exception : Impossible to set selected property....

comment:4 Changed 9 years ago by timmywil

Status: newpending

comment:5 Changed 9 years ago by trac-o-bot

Resolution: invalid
Status: pendingclosed

Because we get so many tickets, we often need to return them to the initial reporter for more information. If that person does not reply within 14 days, the ticket will automatically be closed, and that has happened in this case. If you still are interested in pursuing this issue, feel free to add a comment with the requested information and we will be happy to reopen the ticket if it is still valid. Thanks!

Note: See TracTickets for help on using tickets.