I have an HTML.erb file that defines 2 text_area_tags (input, output)
and 3 submit_to_remote buttons (rewrite, demo, clear). Depending on
which button is clicked, I''d like to call the corresponding Ruby method
on the server and then update the web page. My problem is that, no
matter which button is clicked, the same method (input_output) is always
called. I thought I could set the :action within the button definition
to specify the method to call, but it looks like the :action specified
in the form will always be called. How can I make each button call a
different method? Alternatively, how can I display the name of the
button that was clicked within the method that is being called? The
html.erb file is below. Thank you in advance for your help.
<html>
<head>
<%= javascript_include_tag :defaults %>
<%= stylesheet_link_tag ''input_output'' %>
</head>
<body>
<div id="input_output_form">
<% form_tag(:action=>:input_output) do %>
<%= text_area_tag(:input, params[:input],
:size=>"80x11") %>
<p></p>
<%= submit_to_remote
''Rewrite'',''Rewrite'',
:action=>''rewrite'',
:update=>''input_output_form'',
:html=>{:class=>"btn",
:onmouseover=>"this.className=''btn
btnhov''",
:onmouseout=>"this.className=''btn''"} %>
<%= submit_to_remote ''Demo'',''Demo'',
:action=>:demo,
:update=>''input_output_form'',
:html=>{:class=>"btn",
:onmouseover=>"this.className=''btn
btnhov''",
:onmouseout=>"this.className=''btn''"} %>
<%= submit_to_remote
''Clear'',''Clear'',
:action=>'':clear'',
:update=>''input_output_form'',
:html=>{:class=>"btn",
:onmouseover=>"this.className=''btn
btnhov''",
:onmouseout=>"this.className=''btn''"} %>
<p></p>
<%= text_area_tag(:output, params[:output], :size=>"80x11")
%>
<p></p>
<%= text_area_tag(:scratchpad, params[:scratchpad],
:size=>"80x11") %>
<% end %>
</div>
</body>
</html>
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.