Bug Tracker

Opened 12 years ago

Closed 12 years ago

#8930 closed bug (cantfix)

attr('selected', true); not following the selected item

Reported by: jostster Owned by: Timmy Willison
Priority: low Milestone: 1.next
Component: attributes Version: 1.5.1
Keywords: Cc:
Blocked by: Blocking:

Description

When you use attr('selected', true); on a list box it should scroll to the selected item. It does this for the first case but does not repeat it on the following calls.

EX: http://jsfiddle.net/QnGcm/

Doing this in regular javascript works fine and continues to scroll the select box to the currently selected item.

EX: http://jsfiddle.net/Jd7CE/

Change History (3)

comment:1 Changed 12 years ago by Aknosis

Your tests both work for me in Firefox 4.0 (for the desired effect you are describing).

But your tests are technically not performing the same thing. To mimick what you are doing in the pure JS test you would need to do $('#myselect').val(3); (setting the value on the <select> element) or to swap it around you would need to do document.getElementById('myselect').children[3].selected = true; (setting the selected property to true) on the <option> element)

Aside from that what browser are you testing in?

comment:2 Changed 12 years ago by Timmy Willison

Component: unfiledattributes
Owner: set to Timmy Willison
Priority: undecidedlow
Status: newassigned

I'm not sure there's anything we can do here, but I'll take a look. Unfortunately, your first fiddle would not work in all browsers and as Aknosis noted, your second fiddle is not equivalent to the first. One is setting the value of the select, which you can do with val, and the other is setting attributes on the options. However, thank you for putting together a test case and I put together another test case with val and that does not seem to scroll either (Chromium 12). http://jsfiddle.net/timmywil/Jd7CE/2/

comment:3 Changed 12 years ago by Timmy Willison

Resolution: cantfix
Status: assignedclosed

I don't think there's anything we can do here. Unfortunately setting with .value is not an option even with just one value since if the the value being set does not exist, in IE it will leave everything the same instead of removing the existing selections so we couldn't provide any consistency with the scrolling.

Note: See TracTickets for help on using tickets.