Forum: Ruby on Rails Observing Radio Buttons ??

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Nitin (Guest)
on 2007-02-08 20:38
Observing Radio buttons

I am having some thing like the following code:
// Radio Button with id new_X
<input type="radio" name=" X" id="new_X" value= "new" /> <b> New X</b>

// Observe method on radio button
// test_X method exists in the controller and has a correspondin rhtml
<% observe_field(:new_ X, :frequency => 0.1,
                     :update => :new_X _container,
                     :url => { :action => :test_X })

// Container to change on clicking the radio button.
<div id = "new_ X_container">


Can you please help me as why this does not work ?

Bill W. (Guest)
on 2007-02-08 21:42
(Received via mailing list)
Hi Nitin,

Nitin wrote:
>                     :url => { :action => :test_X })
> %>

Because you've hand-coded the field you're asking Rails to observe.
is server-side technology that generates the html and/or js to send to
browser.  But it only concerns itself with the stuff you tell it you
want it
to concern itself with.  You tell it that by using erb (embedded ruby)
your view files.  Any html you hand-code just gets passed straight
to the browser.  So in the case of your observe_field, Rails has no
knowledge of the form element you're asking it to generate js to
It'll get worse if you've hand-coded the form tags too.

If you're new to Rails, especially if you're coming from something like
you'd really benefit from working through a tutorial or two to get the
of how things work together.  At the risk of self-promotion, we just did
rewrite of Curt Hibb's "Rolling with Ruby on Rails" tutorial to bring it
to date with current (or at least near current) syntax / practices.

I hope you find it helpful.  And welcome to Rails!

Best regards,
This topic is locked and can not be replied to.