I''m having a hard time finding an answer to my question. I would
like to have multiple form actions based on what the user selects.
For example, I trying to do something similar to Amazon Zuggest,
using Ian McDonald''s Ruby/Amazon.
I have three types of searches which translates to 3 actions in the
SearchController. I have a drop down menu like so,
<form method="post" action="search_artists">
<select onchange="document.forms[0].action = options
[selectedIndex].value">
<option value="search_artists" selected>Music</option>
<option value="search_books">Books</option>
<option value="search_actors">DVD</option>
</select>
This works. The problem is, I want to use either form_remote_tag or
something like this:
<%= submit_to_remote("search", "Search",
:url => {:controller => "search", :action
=>
"search_artists"},
:html => {:class => ''search''},
:update => :item,
:method => ''get'') %>)
</form>
<div id="item"></div>
Both of which work perfectly, as the results which I display with a
three different partial templates, are returned without page refresh.
However, in doing so, I am forced to hard code the :action of
submit_to_remote, thereby, disabling the line of javascript in the
select menu.
Does anyone have any ideas on how to implement this ? Sorry that this
is my second time asking this question on this list. I know you''re
all busy, and I know Ruby, but am fairly new to Rails. I''d rather
not use three forms for what should be fairly simple.
Thanks in advance,
Regards, Markus Arike
http://www.michaelarike.com
Hello Markus ! 2005/11/11, Markus Arike <marike1@optonline.net>:> <%= submit_to_remote("search", "Search", > :url => {:controller => "search", :action => > "search_artists"}, > :html => {:class => 'search'}, > :update => :item, > :method => 'get') %>) > > </form> > <div id="item"></div>You know what I would do ? I would put the target of the action in a hidden field, and read that hidden field in the submit_to_remote. Change your :url to: :url => %Q($('id_of_hidden_field').value) WARNING: untested - I don't even know if that'll work. Worth a try, don't you think ? Bye ! François _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
When I do this in php / asp, I have one search action and evaluate the value of the submit button or particular radio / option field... Then just call the appropriate private search action. I''d probably follow that same train of thought here too... Just a suggestion. -----Original Message----- From: rails-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org [mailto:rails-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On Behalf Of Francois Beausoleil Sent: Friday, November 11, 2005 3:58 PM To: rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org Subject: Re: [Rails] Help: Multiple Form Actions Hello Markus ! 2005/11/11, Markus Arike <marike1-p32f3XyCuykqcZcGjlUOXw@public.gmane.org>:> <%= submit_to_remote("search", "Search", > :url => {:controller => "search", :action => > "search_artists"}, > :html => {:class => ''search''}, > :update => :item, > :method => ''get'') %>) > > </form> > <div id="item"></div>You know what I would do ? I would put the target of the action in a hidden field, and read that hidden field in the submit_to_remote. Change your :url to: :url => %Q($(''id_of_hidden_field'').value) WARNING: untested - I don''t even know if that''ll work. Worth a try, don''t you think ? Bye ! François