# :after\_update\_element on text\_field\_with\_auto\_complete

**URL:** <https://www.ruby-forum.com/t/after-update-element-on-text-field-with-auto-complete/57936>\
**Category:** Rails\
**Created:** [April 16, 2006, 5:53pm UTC](https://www.ruby-forum.com/t/after-update-element-on-text-field-with-auto-complete/57936 "2006-04-16T17:53:36Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jdhale](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/7ba0ec/32.png) [@jdhale](https://www.ruby-forum.com/u/jdhale)\
**Post date:** [April 16, 2006, 5:53pm UTC](https://www.ruby-forum.com/t/after-update-element-on-text-field-with-auto-complete/57936/1 "2006-04-16T17:53:36Z")

</div>

I have a a basic prototype coded:

#view  
\<%= text\_field\_with\_auto\_complete :student, :last\_name, { :size =\> 15  
},  
:after\_update\_element =\> “alert(‘hello world’);” %\>

#controller  
class ScoresController \< ApplicationController  
auto\_complete\_for :student, :last\_name  
end

If I take out the :after\_update\_element option everything works as  
advertised. However, with :after\_update\_element specified nothing  
works. The ajax call to the server does not happen.

I am running Rails 1.1.2 on Mac 10.4.6 with Ruby 1.8.4. I am testing  
this with Safari.

Does anyone know why this doesn’t work?

---

<div class="post-metadata">

**Author:** ![jdhale](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/7ba0ec/32.png) [@jdhale](https://www.ruby-forum.com/u/jdhale)\
**Post date:** [April 16, 2006, 7:54pm UTC](https://www.ruby-forum.com/t/after-update-element-on-text-field-with-auto-complete/57936/2 "2006-04-16T19:54:19Z")

</div>

Jason  
\> \<%= text\_field\_with\_auto\_complete :student, :last\_name, { :size  
=\> 15 },  
\> :after\_update\_element =\> “alert(‘hello world’);” %\>

This is the wrong syntax: a function is expected.  
Try instead:  
:after\_update\_element =\> “function(element,value){alert('You have  
chosen: '+value)}”

Alan

---

<div class="post-metadata">

**Author:** ![jdhale](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/7ba0ec/32.png) [@jdhale](https://www.ruby-forum.com/u/jdhale)\
**Post date:** [April 16, 2006, 7:57pm UTC](https://www.ruby-forum.com/t/after-update-element-on-text-field-with-auto-complete/57936/3 "2006-04-16T19:57:42Z")

</div>

oops, typo:

```
> Alan

```

should read :  
Alain.

🙂
