You could use $$(''[selected]'') but it only works if state is
set via
"selected" attribute.
Maybe it would make sense to be able to define custom selectors
(rules) - '':selected'', '':contains'', etc.
Selector.addRules({
''::selected'': function(element) {
return !!element.selected;
}
})
$$(''::selected''); // returns all elements with not falsy
.selected
property
Would allow for a great control, though I can only see 3-4 use cases
at most...
- kangax
On Feb 20, 11:09 pm, "Gareth Evans"
<agr...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> Hey Guys,
>
> I was just trying to determine the selected item in a select box.
> I know there was a discussion a while ago,
> Native js scripting dictates you can use the selectedIndex property or
> iterate over the options and check the opt.selected property.
> I think there''s a way of doing it with multiple selects but I
don''t remember
> the last time I used one of those.
> Anyway, the first thing I tried was
selectBox.select(''option:selected''); and
> was surprised when it didn''t work. Is this not a supported psuedo?
:checked
> is.
>
> var sb = $(''ctl00_PageContent_FollowupUser'');
> alert($(sb.options[sb.selectedIndex])); //native, extends option tag
> alert(sb.select(''option'').find(function(o){ return
o.selected; }); //using
> select without pseudo and enumerable find
> alert(sb.select(''option:selected'')); //would be nice if
this worked
>
> I was testing in IE7, if it''s supported and I just found a bug.
>
> Gareth
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Spinoffs" group.
To post to this group, send email to
rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---