Thanks Fred.

You pointed me in the right direction.

The problem seemed to be in the form_remote_tag element. I changed
"text_field" to "text_field_tag" which got rid of the double params
for description.

I also changed the div name by adding "_div" to it on the possibility
that having the same method and div name might have caused the
confusion.

Then adding a "render :nothing => true" to the search_remote method
cleaned out the div.

In the future, I think I'll add a separate search page.


On Jun 12, 10:52 pm, Frederick Cheung <[email protected]>
wrote:
> 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