eggman2001
2008-Jan-02 05:27 UTC
asking for help with select form helper and observe_field
I have a select form helper and an observe_field that''s observing the select and calling an action when the select changes. However, I''m having trouble passing the right parameters from the select. The select helper is inside of a form_for and looks like: f.select(:name, @books) The observe_field looks like: observe_field :id, :url => { :action => ''index'' } When the post request occurs, I see that the right value parameter from the select is passed, but is of the form: value => nil, which I can''t work with. Can someone lend me a hand? --~--~---------~--~----~------------~-------~--~----~ 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 groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Ryan Bigg
2008-Jan-02 05:32 UTC
Re: asking for help with select form helper and observe_field
you''re observing the wrong field? You''re specifying :id in your observe_field (in the example you gave us) The correct way to do that is: observe_field("object_name", :url => { :action => ''index'' }) How are you specifying the ID for the object? I''m guessing you didn''t specify just :id for it :) On Jan 2, 2008 3:57 PM, eggman2001 <sodani-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > I have a select form helper and an observe_field that''s observing the > select and calling an action when the select changes. However, I''m > having trouble passing the right parameters from the select. > > The select helper is inside of a form_for and looks like: > f.select(:name, @books) > > The observe_field looks like: > observe_field :id, :url => { :action => ''index'' } > > When the post request occurs, I see that the right value parameter > from the select is passed, but is of the form: value => nil, which I > can''t work with. > > Can someone lend me a hand? > > >-- Ryan Bigg frozenplague.net Feel free to add me to MSN and/or GTalk as this email. --~--~---------~--~----~------------~-------~--~----~ 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 groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
s.ross
2008-Jan-02 05:36 UTC
Re: asking for help with select form helper and observe_field
On Jan 1, 2008, at 9:27 PM, eggman2001 wrote:> > I have a select form helper and an observe_field that''s observing the > select and calling an action when the select changes. However, I''m > having trouble passing the right parameters from the select. > > The select helper is inside of a form_for and looks like: > f.select(:name, @books) > > The observe_field looks like: > observe_field :id, :url => { :action => ''index'' } > > When the post request occurs, I see that the right value parameter > from the select is passed, but is of the form: value => nil, which I > can''t work with. > > Can someone lend me a hand?Try this: observe_field ''books_name'', :url => { :action => ''index'' } n.b., you''ll have to look at the id in your HTML to make sure ''books_name'' is right, but the documentation on observe_field is specific that the first argument is the DOM id of the field. If you are still getting nil values, try a second parameter to the hash: :with => "Form.Element.serialize(''your_field_id'')" --~--~---------~--~----~------------~-------~--~----~ 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 groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
eggman2001
2008-Jan-02 05:46 UTC
Re: asking for help with select form helper and observe_field
Had everything right. I just needed to add the :with option. Thanks!! On Jan 2, 12:36 am, "s.ross" <cwdi...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Jan 1, 2008, at 9:27 PM, eggman2001 wrote: > > > > > > > I have a select form helper and an observe_field that''s observing the > > select and calling an action when the select changes. However, I''m > > having trouble passing the right parameters from the select. > > > The select helper is inside of a form_for and looks like: > > f.select(:name, @books) > > > The observe_field looks like: > > observe_field :id, :url => { :action => ''index'' } > > > When the post request occurs, I see that the right value parameter > > from the select is passed, but is of the form: value => nil, which I > > can''t work with. > > > Can someone lend me a hand? > > Try this: > > observe_field ''books_name'', :url => { :action => ''index'' } > > n.b., you''ll have to look at the id in your HTML to make sure > ''books_name'' is right, but the documentation on observe_field is > specific that the first argument is the DOM id of the field. If you > are still getting nil values, try a second parameter to the hash: > > :with => "Form.Element.serialize(''your_field_id'')"--~--~---------~--~----~------------~-------~--~----~ 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 groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---