# Text\_field\_with\_auto\_complete question

**URL:** <https://www.ruby-forum.com/t/text-field-with-auto-complete-question/176449>\
**Category:** Rails\
**Created:** [September 30, 2009, 6:06pm UTC](https://www.ruby-forum.com/t/text-field-with-auto-complete-question/176449 "2009-09-30T18:06:59Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![bigdaddy71](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/bbe5ce/32.png) [@bigdaddy71](https://www.ruby-forum.com/u/bigdaddy71)\
**Post date:** [September 30, 2009, 6:06pm UTC](https://www.ruby-forum.com/t/text-field-with-auto-complete-question/176449/1 "2009-09-30T18:06:59Z")

</div>

This code below will display “Search Friends” in the text box IF  
{:select =\> ‘friend’} is not there and the ajax call also does not  
work. Any ideas how to get the text and to disaply and have the ajax  
call work?

\<%= text\_field\_with\_auto\_complete :friend, :name,{:select =\>  
‘friend’}, :value =\> “Search Friends”, :onfocus =\> “if (this.value ==  
‘Search Friends’) {this.value = ‘’;}”,:onblur =\> “if (this.value ==  
‘’) {this.value = ‘Search Friends’;}”,  
:after\_update\_element =\> “function(element,value){” +  
remote\_function(:url =\> { :controller =\> ‘followerranking’, :action  
=\> :ajax\_add\_friend },  
:with =\> “‘friend[name]=’ + element.value”) + “}” %\>

---

<div class="post-metadata">

**Author:** ![bigdaddy71](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/bbe5ce/32.png) [@bigdaddy71](https://www.ruby-forum.com/u/bigdaddy71)\
**Post date:** [September 30, 2009, 8:02pm UTC](https://www.ruby-forum.com/t/text-field-with-auto-complete-question/176449/2 "2009-09-30T20:02:22Z")

</div>

On Sep 30, 11:05 am, Me [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> remote\_function(:url =\> { :controller =\> ‘followerranking’, :action  
> =\> :ajax\_add\_friend },  
> :with =\> “‘friend[name]=’ + element.value”) + “}” %\>

What do you mean by “not work”? Check your rails log and see if a  
request is hitting your app at all.

Did you include something like \<%= javascript\_include\_tag :defaults %\>  
in your layout or view?

Jeff  
[purpleworkshops.com](http://purpleworkshops.com)

---

<div class="post-metadata">

**Author:** ![bigdaddy71](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/bbe5ce/32.png) [@bigdaddy71](https://www.ruby-forum.com/u/bigdaddy71)\
**Post date:** [September 30, 2009, 8:41pm UTC](https://www.ruby-forum.com/t/text-field-with-auto-complete-question/176449/3 "2009-09-30T20:41:36Z")

</div>

No.  
If the “select” statement is in there the ajax :after\_update works with  
the  
:value=\>"". If it is not then the text displays in the text box for  
:value=\>"", but the  
:after\_update does not work.

---

<div class="post-metadata">

**Author:** ![bigdaddy71](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/bbe5ce/32.png) [@bigdaddy71](https://www.ruby-forum.com/u/bigdaddy71)\
**Post date:** [October 5, 2009, 5:06pm UTC](https://www.ruby-forum.com/t/text-field-with-auto-complete-question/176449/4 "2009-10-05T17:06:17Z")

</div>

anybody?
