I know is a dumb question, but I''m trying to clear a dropdownList in an elegant way. (Note I have prototype 1.5.0 and I can''t use setValue()); I tried: $A($(''select_id'').options).clear() --> does not work (I believe $A returns a new Array) $(''select_id'').clear() --> does not work I''m actually iterating over the options and setting null to everyone of them. I KNOW this can''t be the easiest way of doing it. Does anyone know a better way? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
I think you can just say: $(''select_id'').length = 0; On Thu, Jun 5, 2008 at 10:56 AM, FernandezPablo <fernandezpablo85-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > I know is a dumb question, but I''m trying to clear a dropdownList in > an elegant way. > > (Note I have prototype 1.5.0 and I can''t use setValue()); > > I tried: > > $A($(''select_id'').options).clear() --> does not work (I believe $A > returns a new Array) > $(''select_id'').clear() --> does not work > > I''m actually iterating over the options and setting null to everyone > of them. I KNOW this can''t be the easiest way of doing it.-- Science answers questions; philosophy questions answers. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On Thu, Jun 5, 2008 at 9:56 AM, FernandezPablo <fernandezpablo85-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > I know is a dumb question, but I''m trying to clear a dropdownList in > an elegant way.You could try $(''select_id'').select(''option'').invoke(''remove''); which simply removes the option elements. :Dan --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
The normal way to do this is to set options.length to 0. I don''t know about elegant, but it is a robust solution. Walter On Jun 5, 2008, at 12:05 PM, "Dan Dorman" <dan.dorman-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > On Thu, Jun 5, 2008 at 9:56 AM, FernandezPablo > <fernandezpablo85-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> >> I know is a dumb question, but I''m trying to clear a dropdownList in >> an elegant way. > > You could try > > $(''select_id'').select(''option'').invoke(''remove''); > > which simply removes the option elements. > > :Dan > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
2008/6/5 Walter Lee Davis <waltd-HQgmohHLjDZWk0Htik3J/w@public.gmane.org>:> > The normal way to do this is to set options.length to 0. I don''t know > about elegant, but it is a robust solution. > > Walter > > On Jun 5, 2008, at 12:05 PM, "Dan Dorman" <dan.dorman-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> >> On Thu, Jun 5, 2008 at 9:56 AM, FernandezPablo >> <fernandezpablo85-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>> >>> I know is a dumb question, but I''m trying to clear a dropdownList in >>> an elegant way. >> >> You could try >> >> $(''select_id'').select(''option'').invoke(''remove''); >> >> which simply removes the option elements. >> >> :Dan >> >> > > > > >If you''ve attached observers to any of the options, make sure you stop observing first. -- ----- Richard Quadling Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731 "Standing on the shoulders of some very clever giants!" --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Ok guys, thanks for the advice, I did it like this: options.length = 0 --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Could you say a little more about On Jun 6, 2008, at 4:35 AM, Richard Quadling wrote:> If you''ve attached observers to any of the options, make sure you stop > observing first.I understand what it is to observe the options, but why would you observe individual options of a select? I usually observe the select itself, and removing all the options does not change the observer at all. I''ve used this pattern a lot for "magic" pickers in calendars. Walter --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---