I have a <select multiple="multiple"> list with a fixed height.
It
contains several <option> elements that extend well past the viewable
area. I added code that would track which options had been previously
selected so that users could select multiple items without holding the
ctrl key.
I''m storing the previous selections in an array whose index
corresponds with the options list. After a new selection is made
(which automatically de-selects the other options) I loop through the
list and restore the selected attribute based on the settings saved in
the array like this:
$$(''#payorList option'').each(function(opt){
opt.selected = payorOptions[opt.index]; //
payorOptions is the array
});
An unintended consequence is that the select list is scrolled to the
bottom as I iterate through each one, forcing the user to manually
scroll back up to select another option.
I''ve tried using Element.scrollTo(), but it scrolls the whole page,
and I''m doing a rotten job of figuring out how to use scroll offsets
and wondering if they''re applicable to a <select>.
I''m hoping someone can suggest a strategy to either update the
<option> elements without scrolling the <select> list, or a way that
I
can scroll back to the last option clicked.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
ESPNDev-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2008-Mar-13 22:17 UTC
Re: scrolling in a <select multiple="multiple"> list
James, try this:
$$(''#payorList option'').reverse.each(function(opt){
opt.selected = payorOptions[opt.index]; //
payorOptions is the array
});
On Mar 13, 10:59 am, James
<JamesJReyno...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> I have a <select multiple="multiple"> list with a fixed
height. It
> contains several <option> elements that extend well past the viewable
> area. I added code that would track which options had been previously
> selected so that users could select multiple items without holding the
> ctrl key.
>
> I''m storing the previous selections in an array whose index
> corresponds with the options list. After a new selection is made
> (which automatically de-selects the other options) I loop through the
> list and restore the selected attribute based on the settings saved in
> the array like this:
>
> $$(''#payorList option'').each(function(opt){
> opt.selected = payorOptions[opt.index]; //
> payorOptions is the array
> });
>
> An unintended consequence is that the select list is scrolled to the
> bottom as I iterate through each one, forcing the user to manually
> scroll back up to select another option.
>
> I''ve tried using Element.scrollTo(), but it scrolls the whole
page,
> and I''m doing a rotten job of figuring out how to use scroll
offsets
> and wondering if they''re applicable to a <select>.
>
> I''m hoping someone can suggest a strategy to either update the
> <option> elements without scrolling the <select> list, or a way
that I
> can scroll back to the last option clicked.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
That is really cool. I never noticed that method before. In my case, there are so many options that it just reverses my problem. I went ahead and did what I should have done in the first place and built a custom object to handle my needs. Nevertheless, I''ll definitely be using reverse() for other things in the future. Thanks for the suggestion. JR On Mar 13, 4:17 pm, "ESPN...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org" <ESPN3.DL- Community...-xX8xgfAcNKEAvxtiuMwx3w@public.gmane.org> wrote:> James, try this: > > $$(''#payorList option'').reverse.each(function(opt){ > opt.selected = payorOptions[opt.index]; // > payorOptions is the array > }); > > On Mar 13, 10:59 am, James <JamesJReyno...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > I have a <select multiple="multiple"> list with a fixed height. It > > contains several <option> elements that extend well past the viewable > > area. I added code that would track which options had been previously > > selected so that users could select multiple items without holding the > > ctrl key. > > > I''m storing the previous selections in an array whose index > > corresponds with the options list. After a new selection is made > > (which automatically de-selects the other options) I loop through the > > list and restore the selected attribute based on the settings saved in > > the array like this: > > > $$(''#payorList option'').each(function(opt){ > > opt.selected = payorOptions[opt.index]; // > > payorOptions is the array > > }); > > > An unintended consequence is that the select list is scrolled to the > > bottom as I iterate through each one, forcing the user to manually > > scroll back up to select another option. > > > I''ve tried using Element.scrollTo(), but it scrolls the whole page, > > and I''m doing a rotten job of figuring out how to use scroll offsets > > and wondering if they''re applicable to a <select>. > > > I''m hoping someone can suggest a strategy to either update the > > <option> elements without scrolling the <select> list, or a way that I > > can scroll back to the last option clicked.--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
ESPNDev-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2008-Mar-14 02:51 UTC
Re: scrolling in a <select multiple="multiple"> list
Oh, yeah, i thought about that, too after the fact. Well, glad you got it resolved. On Mar 13, 3:25 pm, James <JamesJReyno...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> That is really cool. I never noticed that method before. In my case, > there are so many options that it just reverses my problem. I went > ahead and did what I should have done in the first place and built a > custom object to handle my needs. > > Nevertheless, I''ll definitely be using reverse() for other things in > the future. Thanks for the suggestion. > > JR > > On Mar 13, 4:17 pm, "ESPN...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org" <ESPN3.DL- > > Community...-xX8xgfAcNKEAvxtiuMwx3w@public.gmane.org> wrote: > > James, try this: > > > $$(''#payorList option'').reverse.each(function(opt){ > > opt.selected = payorOptions[opt.index]; // > > payorOptions is the array > > }); > > > On Mar 13, 10:59 am, James <JamesJReyno...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > I have a <select multiple="multiple"> list with a fixed height. It > > > contains several <option> elements that extend well past the viewable > > > area. I added code that would track which options had been previously > > > selected so that users could select multiple items without holding the > > > ctrl key. > > > > I''m storing the previous selections in an array whose index > > > corresponds with the options list. After a new selection is made > > > (which automatically de-selects the other options) I loop through the > > > list and restore the selected attribute based on the settings saved in > > > the array like this: > > > > $$(''#payorList option'').each(function(opt){ > > > opt.selected = payorOptions[opt.index]; // > > > payorOptions is the array > > > }); > > > > An unintended consequence is that the select list is scrolled to the > > > bottom as I iterate through each one, forcing the user to manually > > > scroll back up to select another option. > > > > I''ve tried using Element.scrollTo(), but it scrolls the whole page, > > > and I''m doing a rotten job of figuring out how to use scroll offsets > > > and wondering if they''re applicable to a <select>. > > > > I''m hoping someone can suggest a strategy to either update the > > > <option> elements without scrolling the <select> list, or a way that I > > > can scroll back to the last option clicked.--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---