Joshua Kolden
2008-May-14 05:22 UTC
multiple images_submit_tag *all* "names" are given as parameters
I have a form like so:
<% form_remote_tag(:url => { :action => :foo}, :complete =>
"do_some_cool_ajax(request);") do %>
<%= text_field_tag :myInput, params[:myInput], :size => 80
%></p>
<div id="coolButtons">
<p><%= submit_tag "do function 1", :name =>
"f1"%></p>
<p><%= submit_tag "do funciton 2", :name =>
"f2"%></p>
</div>
<div id="coolImages">
<%= image_submit_tag("function3.png", :name =>
"f3")%>
<%= image_submit_tag("function4.png", :name =>
"f4")%>
<%= image_submit_tag("function5.png", :name =>
"f5")%>
<%= image_submit_tag("function6.png", :name =>
"f6")%>
</div>
<% end %>
I would hope to get parameters that have only one of the names so that
I can test like so
if params["f1"]
# do some f1 stuff
else if params["f2"]
# do some f2 stuff
else...
For this to work I need something like this in params:
Example 1: Parameters: {"f1"=>"",
"action"=>"foo",
"controller"=>"bar",
"myInput"=>"foobar"}
However I''m getting
Example 2: Parameters: {"f1"=>"",
"f2"=>"", "f3"=>"",
"f4"=>"",
"f5"=>"", "f6"=>"",
"action"=>"foo",
"controller"=>"bar",
"myInput"=>"foobar"}
Any ideas on how to isolate each of these actions so that I know which
submit was actually sent? Google searching lists a buch of sites that
say Example 1 should work.
I''ve tested on osx both firefox and safari and I get the same results.
--~--~---------~--~----~------------~-------~--~----~
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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
Joshua Kolden
2008-May-17 18:18 UTC
Re: multiple images_submit_tag *all* "names" are given as parameters
For reference. It turns out that the Prototype library is not designed to handle multiple submits of this type in an Ajax form. It is a limitation that may be addressed in the future. In the meantime it appears that the best answer is to create a hidden field, and fill it with a value when a image is clicked. j On May 13, 10:22 pm, Joshua Kolden <crackcreat...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I have a form like so: > > <% form_remote_tag(:url => { :action => :foo}, :complete => > "do_some_cool_ajax(request);") do %> > <%= text_field_tag :myInput, params[:myInput], :size => 80 %></p> > <div id="coolButtons"> > <p><%= submit_tag "do function 1", :name => "f1"%></p> > <p><%= submit_tag "do funciton 2", :name => "f2"%></p> > </div> > <div id="coolImages"> > <%= image_submit_tag("function3.png", :name => "f3")%> > <%= image_submit_tag("function4.png", :name => "f4")%> > <%= image_submit_tag("function5.png", :name => "f5")%> > <%= image_submit_tag("function6.png", :name => "f6")%> > </div> > <% end %> > > I would hope to get parameters that have only one of the names so that > I can test like so > > if params["f1"] > # do some f1 stuff > else if params["f2"] > # do some f2 stuff > else... > > For this to work I need something like this in params: > > Example 1: Parameters: {"f1"=>"", "action"=>"foo", > "controller"=>"bar", "myInput"=>"foobar"} > > However I''m getting > > Example 2: Parameters: {"f1"=>"", "f2"=>"", "f3"=>"", "f4"=>"", > "f5"=>"", "f6"=>"", "action"=>"foo", "controller"=>"bar", > "myInput"=>"foobar"} > > Any ideas on how to isolate each of these actions so that I know which > submit was actually sent? Google searching lists a buch of sites that > say Example 1 should work. > > I''ve tested on osx both firefox and safari and I get the same results.--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---