I’m trying to add a simple search to an index page of my project. It
takes a term, does a ‘like’ query and populates a common partial which
is displayed with javascript in the div ‘search_remote’.
It runs fine, once. If you run multiple queries without hiding the
div, it works fine. If you close the div and attempt to search again
you get nothing. The console shows that the controller method is
firing but the div isn’t getting updated.
In the view:
<% form_remote_tag :update=> “search_remote”,:url => { :action =>
“search_remote” } do %>
<%= ‘Search for Description:’ %>
<%= text_field “description”, “description” %>
<%= submit_tag ‘find’ %>
<% end %>
In the controller:
def search_remote
if params[:description]
search_term = params[:description][:description]
search_term = ‘%’ + search_term + ‘%’
@search_results = Item.find(:all, :conditions => [“description
LIKE ?”, search_term])
render :partial => “search_remote”, :locals => {:aGroup =>
@search_results, :show_hide => 1, :aToken=> ‘search_remote’}
In the partial _search_remote:
<%= link_to_remote ‘hide’,
:update => ‘search_remote’,
:url => {:action => “search_remote”, :token => ‘search_remote’ },
:complete => visual_effect( :blind_up, ‘search_remote’, :duration =>
0.2 )
%>
Thanks