Jorge Mario G. Mazo
2007-Mar-10 08:35 UTC
how to use :with =>"this.value" in a collection select?
hi there I have this code <%= collection_select ''address'', ''address'', @addresses, :id, :address,{}, :onchange => remote_function(:update => ''shipping'', :url => { :action => :boota }, :with => "''boo''=this.value") %> but in the controller @boo = params[:boo] never gets the value can anyone help me with this google has been no help thanks in advance --~--~---------~--~----~------------~-------~--~----~ 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?hl=en -~----------~----~----~----~------~----~------~--~---
Bill Walton
2007-Mar-10 14:59 UTC
Re: how to use :with =>"this.value" in a collection select?
Hi Jorge, Jorge Mario G. Mazo wrote:> <%= collection_select ''address'', ''address'', @addresses, :id, :address,{}, > :with => "''boo''=this.value") %> > > but in the controller > @boo = params[:boo] never gets the valueThe documentation on :with could definitely use some work, IMHO ;-) The good new is, all you need is :with => ''boo'' This puts the value in params[:boo] Adding the ''='' after ''boo'' tells Rails you''re going to get fancy, which it will certainly help you with if you want to do something like serialize all or some of the elements in a form to pass them back in a multi-level hash independent of the actual form submission. It doesn''t sound like that''s not what you''re trying to do, though. hth, Bill --~--~---------~--~----~------------~-------~--~----~ 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?hl=en -~----------~----~----~----~------~----~------~--~---
Jorge Mario G. Mazo
2007-Mar-11 06:18 UTC
Re: how to use :with =>"this.value" in a collection select?
hi there sir and sorry to bother but it doesnt work if I put some crazy in the :with I see an empty (--) debuging message but if I use :with => ''boo'' nothing happens this is what I have in my _form.rhtml <%= collection_select ''address'', ''address'', @addresses, :id, :address,{}, :onchange => remote_function( :update => ''shipping'', :url => { :action => :boota }, :with => ''boo'') %></p> in the controller def boota @pp = params[:boo] render(:partial => ''bo'' ) end and this is _bo.rhtml <%= debug(@pp) %> I dont really know what am I doing wrong but I cant make it work thanks in advance -- Jorge Mario G. Mazo On 3/10/07, Bill Walton <bill.walton-xwVYE8SWAR3R7s880joybQ@public.gmane.org> wrote:> > Hi Jorge, > > Jorge Mario G. Mazo wrote: > > <%= collection_select ''address'', ''address'', @addresses, :id, :address,{}, > > :with => "''boo''=this.value") %> > > > > but in the controller > > @boo = params[:boo] never gets the value > > The documentation on :with could definitely use some work, IMHO ;-) The > good new is, all you need is > > :with => ''boo'' > > This puts the value in params[:boo] > > Adding the ''='' after ''boo'' tells Rails you''re going to get fancy, which it > will certainly help you with if you want to do something like serialize all > or some of the elements in a form to pass them back in a multi-level hash > independent of the actual form submission. It doesn''t sound like that''s not > what you''re trying to do, though. > > hth, > Bill > > > > > >--~--~---------~--~----~------------~-------~--~----~ 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?hl=en -~----------~----~----~----~------~----~------~--~---
Bill Walton
2007-Mar-11 08:37 UTC
Re: how to use :with =>"this.value" in a collection select?
Hi Jorge, Jorge Mario G. Mazo wrote:> hi there sir and sorry to bother but it doesnt work > if I put some crazy in the :with I see an empty (--) > debuging message > > but if I use :with => ''boo'' nothing happens > > this is what I have in my _form.rhtml > > <%= collection_select ''address'', ''address'', @addresses, :id, > :address,{}, :onchange => remote_function( > :update => ''shipping'',> > :url => { :action => :boota }, > :with => ''boo'') %></p>First, I''ll apologize in advance for my brief reply. It''s very late here and I must sign-off quickly or risk wife-ly reprecussions. Hope you understand :-) My recommendation / personal strategy in situations like this it simple. Make it simple. By that I mean, generate a sandbox app with just the bare minimum of stuff in it to get the behavior you''re looking for working. For starters, I''d get rid of the :onchange stuff.in the collection_select and, once I got that working, put an observe_field on it. Then, and only then, would I try to combine them. Again, sorry I can''t be more help tonight. Time to retire. Hope to hear back. Best regards, Bill --~--~---------~--~----~------------~-------~--~----~ 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?hl=en -~----------~----~----~----~------~----~------~--~---
Bill Walton
2007-Mar-11 08:52 UTC
Re: how to use :with =>"this.value" in a collection select?
Sorry. Just shows how very late it is here. I just looked at my response, then the docs, and realized that collection_select doesn''t do what you''re trying to do. Use collection_select to generate the select box and observe_field :with => ''boo'' to get the selection to your controller method. Be back in the AM. Best regards, Bill --~--~---------~--~----~------------~-------~--~----~ 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?hl=en -~----------~----~----~----~------~----~------~--~---
Jorge Mario G. Mazo
2007-Mar-12 05:46 UTC
Re: how to use :with =>"this.value" in a collection select?
thank you sir, it worked but now I have a new problem if the collection_select only has 1 item the observe field will not work it works perfect with more than 1 thanks for all your help! here is my new code: <%= collection_select ''address'', ''address'', @addresses, :id, :address %></p> <%= observe_field( :address_address, :update => ''shipping'', :url => { :action => :shi }, :complete => "new Effect.SlideDown(''shipping'')", :with => ''boo'') %> As I read that obseve_fields take the same arguments of link_to_remote i have tried :on => click focus change but no luck if theer is only one item in the collection it wont work On 3/11/07, Bill Walton <bill.walton-xwVYE8SWAR3R7s880joybQ@public.gmane.org> wrote:> > Sorry. Just shows how very late it is here. I just looked at my response, > then the docs, and realized that collection_select doesn''t do what you''re > trying to do. Use collection_select to generate the select box and > observe_field :with => ''boo'' to get the selection to your controller method. > > Be back in the AM. > > Best regards, > Bill > > > > > >--~--~---------~--~----~------------~-------~--~----~ 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?hl=en -~----------~----~----~----~------~----~------~--~---