Hi, I have a select in my form: <%= select @issue_type, "name", @issue_types.collect {|p| [p.name, p.id]} %> What I need to do is execute a method passing the value selected in the combo. I''ve tried lot of things, but I couldn''t. @issue_type is created in the controller and I assigned the first value in the collection. Of course, this is the value I only can pass. To retrieve the value in the combo I''ve tried with onchange, but... I couldn''t make it work Thanks in advance -- Posted via http://www.ruby-forum.com/. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 3 September 2010 11:35, Alfredo Bonilla <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Hi, > > I have a select in my form: > > <%= select @issue_type, "name", @issue_types.collect {|p| [p.name, > p.id]} %> > > What I need to do is execute a method passing the value selected in the > combo. I''ve tried lot of things, but I couldn''t.Where are you trying to execute the method? In the browser or in the server? If in the browser then you will have to use javascript (in which case it is not really a Rails question), if in the server then put the select in a form and the selected value will be passed in params when the form is submitted. Colin -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
What I usually do is get things working without Ajax first. Assuming you''ve done that, does onchange trigger anything in the logs? Using firebug or the developer tools in chrome/safari could tell you a lot too. Luke On Sep 4, 1:03 am, Colin Law <clan...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> On 3 September 2010 11:35, Alfredo Bonilla <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: > > > Hi, > > > I have a select in my form: > > > <%= select @issue_type, "name", @issue_types.collect {|p| [p.name, > > p.id]} %> > > > What I need to do is execute a method passing the value selected in the > > combo. I''ve tried lot of things, but I couldn''t. > > Where are you trying to execute the method? In the browser or in the > server? If in the browser then you will have to use javascript (in > which case it is not really a Rails question), if in the server then > put the select in a form and the selected value will be passed in > params when the form is submitted. > > Colin-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Again answering to myself... I solved the problem by: 1-Using *link_to_remote* using :with clause, and passing as serialize the id of the div that I had to create sourranding the select 2-In the controller, once taked the parm and maked all the operations, use *respond_to* js and reloading the page. Probably not the best solution... but it works! -- Posted via http://www.ruby-forum.com/. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.