Forum: Ruby on Rails using 'onchange' option in select from a partial to update a

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
83e3f1e3162b3e50b99966a8448476c7?d=identicon&s=25 rafuzo (Guest)
on 2006-03-29 00:13
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
This topic is locked and can not be replied to.