Tate Hansen
2006-Oct-18 03:55 UTC
observe_field w/check_box (how do you capture unchecked event?)
Hi: Does observe_field work w/check_box? When a checkbox is checked, all works. When it is unchecked, I get "undefined" for params[:option]. more info on what I''m using: ----------------------- my check_box method produces this: <input type="checkbox" value="1" name="option[R]" id="option_R"/> <input type="hidden" value="0" name="option[R]"/> my observe_field is: <%= observe_field "option_#{option}", :update => ''commandLine'', :url => {:action => ''updateCommand''}, :with => ''option'', :on => ''click'' %> --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Jonathan Viney
2006-Oct-18 05:02 UTC
Re: observe_field w/check_box (how do you capture unchecked event?)
For one of my applications the observer passes "1" when it is checked and "undefined" when it isn''t. "undefined" should probably be "0", but you can still tell whether or not it is checked. -Jonathan. On 10/18/06, Tate Hansen <tate-yND1hqhjdFzIa13z/PHSgg@public.gmane.org> wrote:> > > Hi: Does observe_field work w/check_box? > > When a checkbox is checked, all works. When it is unchecked, I get > "undefined" for params[:option]. > > > > more info on what I''m using: > ----------------------- > my check_box method produces this: > > <input type="checkbox" value="1" name="option[R]" id="option_R"/> > <input type="hidden" value="0" name="option[R]"/> > > my observe_field is: > > <%= observe_field "option_#{option}", > :update => ''commandLine'', > :url => {:action => ''updateCommand''}, > :with => ''option'', > :on => ''click'' %> > > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Philip Hallstrom
2006-Oct-18 05:16 UTC
Re: observe_field w/check_box (how do you capture unchecked event?)
> For one of my applications the observer passes "1" when it is checked and > "undefined" when it isn''t. "undefined" should probably be "0", but you can > still tell whether or not it is checked.Maybe... but since there''s no "unchecked_value" attribute it really is undefined... I think you''d be safer testing to see... if params[:option] != "1" then.... where "1" is the value of the ''value'' attribute. Cause some web browser might just decide to start returning false or nil or 0 instead of ''undefined'' so you''re test for ''undefined'' would then fail... Just a thought.> > -Jonathan. > > On 10/18/06, Tate Hansen <tate-yND1hqhjdFzIa13z/PHSgg@public.gmane.org> wrote: >> >> >> Hi: Does observe_field work w/check_box? >> >> When a checkbox is checked, all works. When it is unchecked, I get >> "undefined" for params[:option]. >> >> >> >> more info on what I''m using: >> ----------------------- >> my check_box method produces this: >> >> <input type="checkbox" value="1" name="option[R]" id="option_R"/> >> <input type="hidden" value="0" name="option[R]"/> >> >> my observe_field is: >> >> <%= observe_field "option_#{option}", >> :update => ''commandLine'', >> :url => {:action => ''updateCommand''}, >> :with => ''option'', >> :on => ''click'' %> >> >> >>> >> > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Tate Hansen
2006-Oct-18 05:16 UTC
Re: observe_field w/check_box (how do you capture unchecked event?)
I forgot to mention I have lots of checkboxes for this view, so I can''t determine which box the uncheck was triggered from because of the ''undefined''. From: rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org [mailto:rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org] On Behalf Of Jonathan Viney Sent: Tuesday, October 17, 2006 11:03 PM To: rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Subject: [Rails] Re: observe_field w/check_box (how do you capture unchecked event?) For one of my applications the observer passes "1" when it is checked and "undefined" when it isn''t. "undefined" should probably be "0", but you can still tell whether or not it is checked. -Jonathan. On 10/18/06, Tate Hansen <tate-yND1hqhjdFzIa13z/PHSgg@public.gmane.org> wrote: Hi: Does observe_field work w/check_box? When a checkbox is checked, all works. When it is unchecked, I get "undefined" for params[:option]. [..] --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---