Skip to main content

Bug Tracker

Side navigation

#8930 closed bug (cantfix)

Opened April 21, 2011 12:44AM UTC

Closed April 23, 2011 11:23PM UTC

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

Reported by: jostster Owned by: timmywil
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/

Attachments (0)
Change History (3)

Changed April 22, 2011 05:22AM UTC by Aknosis comment:1

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?

Changed April 22, 2011 01:54PM UTC by timmywil comment:2

component: unfiledattributes
owner: → timmywil
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/

Changed April 23, 2011 11:23PM UTC by timmywil comment:3

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.