On Jun 12, 10:51 pm, AGoofin <[email protected]> wrote:
> 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.
>
Doesn't look like you ever show the div after hiding it.

Fred

> 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 %>
>   <div id="search_remote">
>   </div>
>
> 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

-- 
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 [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to