I’m sure this is a simple problem, but I’ve been working on it for a
couple days and can’t seem to figure out the correct way to structure my
observe_field call. The HTML and Javascript generated all appear
correct, but the AJAX call is never made. Below is the code I’m using
and any help would be much appreciated.
models_controller.rb
def display_compatible
render :partial => “compatible”
end
( Right now the _compatible.rhtml file contains a single HTML statement
just for testing. Going to localhost:3000/app/models/display_compatible
displays the test statement correctly. )
views/new.rhtml
<%= javascript_include_tag “prototype” %>
New model
<%= start_form_tag :action => ‘create’ %>
<%= render_partial ‘form’ %>
<%= submit_tag “Create” %>
<%= end_form_tag %>
<%= observe_field(“model_switchtype”,
:frequency => 0.5,
:update => :compatible,
:url => { :action => :display_compatible }) %>
<%= link_to ‘Back’, :action => ‘list’ %>
( Still using the basic scaffold generated code at the moment. )
views/_form.rhtml
<%= error_messages_for ‘model’ %>
Name
<%= text_field 'model', 'name' %>
Connectionpoints
<%= text_field 'model', 'connectionpoints' %>
Type
<%= radio_button("models", "switchtype", "1") %> Fixed
<%= radio_button("models", "switchtype", "2") %> Modular
<%= radio_button("models", "switchtype", "3") %> Blade
Notes
<%= text_area 'model', 'notes' %>
What I’m trying to do is monitor the radio button field for a change,
and on a change display another set of entry boxes, but am pretty well
stuck.
Thanks in advance.