[Rails] form_remote_tag problems with post url
Sidney Burks
sid137 at gmail.com
Wed Sep 20 11:22:15 GMT 2006
Hi,
I'm hitting a bump with the form_remote_tag, and wondering if anyone can
help.. SO i'm trying to implement a tag-based search on a site and using
routes, I can enter a url such as http://localhost/tag/query , which calls
an action 'search', and returns all the posts which are tagged with the word
'query'..
fine...
In the search.rhtml page, I have a search form, that has several
filter/search options (in the select tags), and below that, there are the
results which are updated in a results div. It essentially looks like the
following:
--------------------------------
search.rhtml -----------------------------------
<%= form_remote_tag(:update => 'search_results', :url => {:action =>
:search}, :loading => 'SearchController.disableSearchForm()', :complete => '
SearchController.enableSearchForm()', :id => 'search_form')%>
<%= select(:search, :selection, [['Newest First', 'new'],['Most Popular
First','popular']]) %>
<% select(:search, :time, [['Today', 'day'],['Last Week','week'],['Last
Month', 'month'],['Last Year','year']], {:selected => 'month'}) %>
<%= select(:search, :field, [['Search By Title', 'title'],['Title and
Descriptions','description'],['Tags', 'tag']]) %>
<%= text_field_tag 'query'%>
<%= submit_tag 'Search', :action => 'search', :onsubmit => '
SearchController.disableSearchForm();' %>
<%= end_form_tag %>
<div id='search_results'>
<%= render :partial => 'search_results' %>
</div>
---------------------------- end
search.rhtml---------------------
As you can see, I'm using the following syntax in the form_remote tag:
form_remote_tag(:update => 'search_results', :url => {:action =>
:search},...
hoping that it will generate html that will post the form to
http://localhost/search. Keep in mind that at this point, the url of the
page this form is on is currently http://localhost/tag/query (from the
previous tag search) When I examine the html source however, or use
Firebug to look at the request, I see that the form is still being POSTed to
http://localhost/tag/query, and not http://localhost/search as I expect..
the html looks like this:
---------------------------- generated html
---------------------
<form action="/tag/yard" method="post" onsubmit="new
Ajax.Updater('search_results', '/tag/yard',
---------------------------- end
generated.rhtml---------------------
So the question is, what am I doing wrong, and how can I make it post to the
'search' action, and not the current url of the page?
Thanks,
-Sidney
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060920/9d8f4359/attachment.html
More information about the Rails
mailing list