# Form\_remote\_tag running only once

**URL:** <https://www.ruby-forum.com/t/form-remote-tag-running-only-once/190232>\
**Category:** Rails\
**Created:** [June 17, 2010, 4:22pm UTC](https://www.ruby-forum.com/t/form-remote-tag-running-only-once/190232 "2010-06-17T16:22:28Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![AGoofin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a3d4f5/32.png) [@AGoofin](https://www.ruby-forum.com/u/AGoofin)\
**Post date:** [June 17, 2010, 4:22pm UTC](https://www.ruby-forum.com/t/form-remote-tag-running-only-once/190232/1 "2010-06-17T16:22:28Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![AGoofin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a3d4f5/32.png) [@AGoofin](https://www.ruby-forum.com/u/AGoofin)\
**Post date:** [June 17, 2010, 4:26pm UTC](https://www.ruby-forum.com/t/form-remote-tag-running-only-once/190232/2 "2010-06-17T16:26:21Z")

</div>

On Jun 12, 10:51 pm, AGoofin [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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

---

<div class="post-metadata">

**Author:** ![AGoofin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a3d4f5/32.png) [@AGoofin](https://www.ruby-forum.com/u/AGoofin)\
**Post date:** [June 17, 2010, 4:27pm UTC](https://www.ruby-forum.com/t/form-remote-tag-running-only-once/190232/3 "2010-06-17T16:27:02Z")

</div>

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 C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
