Jaroslaw Zabiello
2006-Jun-28 23:10 UTC
[Rails] observe_field and radio button... does not work?
I try to catch click event on radio button, but nothing is executed.... Tested with RoR 1.1.2 and 1.1.3. What am I doing wrong? <%= radio_button_tag(:city, ''Dublin'') %> <%= observe_field(:citi, :frequency => 0.5, :on => ''click'', :with => "''city='' + $F(''citi'')", :url => { :action => ''remote_city_choosen'' }) %> ... def remote_city_choosen puts ''#'' * 60 # nothing is displayed p params[:citi] # on the console :( end -- Jaroslaw Zabiello http://blog.zabiello.com -- Posted via http://www.ruby-forum.com/.
Jaroslaw Zabiello
2006-Jun-28 23:14 UTC
[Rails] observe_field and radio button... does not work?
I try to catch click on radio button, but nothing is executed.... Tested with RoR 1.1.2 and 1.1.3. What am I doing wrong? <%= radio_button_tag(:city, ''Dublin'') %> <%= observe_field(:citi, :frequency => 0.5, :on => ''click'', :with => "''city='' + $F(''citi'')", :url => { :action => ''remote_city_choosen'' }) %> ... def remote_city_choosen puts ''#'' * 60 # nothing is displayed p params[:citi] # on the console :( end -- Jaroslaw Zabiello http://blog.zabiello.com -- Posted via http://www.ruby-forum.com/.
Bharat Ahluwalia
2006-Jun-29 00:23 UTC
[Rails] Re: observe_field and radio button... does not work?
> From: Jaroslaw Zabiello <hipertracker@gmail.com> > Subject: [Rails] observe_field and radio button... does not work? > To: rails@lists.rubyonrails.org > Message-ID: <91bcb317f3a4897d8451b640e6a620c3@ruby-forum.com> > Content-Type: text/plain; charset=utf-8 > > I try to catch click on radio button, but nothing is executed.... > Tested with RoR 1.1.2 and 1.1.3. What am I doing wrong? > > <%= radio_button_tag(:city, ''Dublin'') %> > > <%= observe_field(:citi, :frequency => 0.5, > :on => ''click'', > :with => "''city='' + $F(''citi'')", > :url => { :action => > ''remote_city_choosen'' }) > %> > ... > def remote_city_choosen > puts ''#'' * 60 # nothing is displayed > p params[:citi] # on the console :( > endI think this is a simple typo issue, your field is named city, whereas you are observing citi :) Bharat
Bill Walton
2006-Jun-29 00:25 UTC
[Rails] observe_field and radio button... does not work?
Hi Jaroslaw, Jaroslaw Zabiello wrote: Just worked through some issues with this myself so...> <%= radio_button_tag(:city, ''Dublin'') %> > > <%= observe_field(:citi, :frequency => 0.5,Two things here: The first parameter to observe_field is the id of the field you''re observing. In your case the line should start <%= observe_field(''city'' ... I''m not sure if a symbol will work. If it does, great. If not, go to a quoted string in both the radio_button_tag and observe_field statements. The default for radio_button is onchange so, unless you''ve some other reason for wanting to monitor it, you don''t need the :frequency setting.> :on => ''click'',Again, the default is for a radio_button is ''onchange''. You don''t need the :on.> :with => "''city='' + $F(''citi'')",The explanation in the documentation for the :with option is, IMHO, entirely incomprehensible. That''s probably because you can do more complicated stuff with it than most folks want/need to do. What :with does, in cases like yours, is allow you to name the param in which the value in the field you''re observing will come back. So to get the value in the controller with params[:city], all you need is :with => ''city''. hth, Bill