rafuzo
2006-Mar-28 22:48 UTC
[Rails] using ''onchange'' option in select from a partial to update a
I''m new to Rails and don''t totally understand some of the control behavior of ActionController. Here''s my problem: I have a _header.rhtml partial view that is supposed to be the header (naturally) on a main.rhtml view (i.e., main.rhtml calls the header partial via the render method). In the header view is a select field that I''d like to have refresh the main.rhtml view (altering the view based on the selected value) but I''m having a hard time understanding the mechanics of the observe_field method. Here''s my _header partial: <%= start_form_tag :action => ''main'' %> <div="tspan"> <%= select(:timespan, :span, ["1 week", "1 month", "3 months", "6 months", "1 year"], :onchange => ''main'') %> </div> <%= end_form_tag %> <%= observe_field( :timespan, :frequency => 0.25, :update => ''clientresults'', :url => {:action =>:main}, :with => ":timespan") %> So I''m looking to set an instance variable in the main method in my controller with the value of the select, and then have the main method called again with that instance variable set. I know this code is broken but I don''t know how. Can anyone help? Thanks -- Posted via http://www.ruby-forum.com/.