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

**URL:** <https://www.ruby-forum.com/t/after-update-element-and-text-field-with-auto-complete/157018>\
**Category:** Rails\
**Created:** [January 6, 2009, 2:53pm UTC](https://www.ruby-forum.com/t/after-update-element-and-text-field-with-auto-complete/157018 "2009-01-06T14:53:59Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sweetpete](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c5a1d2/32.png) [@sweetpete](https://www.ruby-forum.com/u/sweetpete)\
**Post date:** [January 6, 2009, 2:53pm UTC](https://www.ruby-forum.com/t/after-update-element-and-text-field-with-auto-complete/157018/1 "2009-01-06T14:53:59Z")

</div>

Hi!  
I’m on Rails 2.2.2 and using text\_field\_with\_auto\_complete which works  
fine.

Now I want to use :after\_update\_element to send some data back to the  
server when my text field is updated.

I have the following code in my view:

\<%= text\_field\_with\_auto\_complete :company, :name, {},  
{:after\_update\_element =\>  
“function(element,value){” + remote\_function(  
:url =\> { :action =\> :update\_search\_session },  
:with =\>"‘selected\_company\_name=’+element.value") + “}”,  
:skip\_style =\> false, :method =\> :get }  
%\>

I can see that my controller method (:update\_search\_session) gets called  
allright but I can’t figure out how to access the returned data  
(element.value).

Can anyone help?

TIA, Peter

---

<div class="post-metadata">

**Author:** ![sweetpete](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c5a1d2/32.png) [@sweetpete](https://www.ruby-forum.com/u/sweetpete)\
**Post date:** [January 8, 2009, 7:31pm UTC](https://www.ruby-forum.com/t/after-update-element-and-text-field-with-auto-complete/157018/2 "2009-01-08T19:31:27Z")

</div>

Peter Jeppesen wrote:

> Am I totally misunderstanding something here or…  
> Please help! - I’m really stuck on this!

OK finally I got it sorted out.  
After a minor bugfix in my javascript, params[:selected\_company\_name]  
did the trick.

Amazing and smooth… - I just love Rails!

Peter

---

<div class="post-metadata">

**Author:** ![sweetpete](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c5a1d2/32.png) [@sweetpete](https://www.ruby-forum.com/u/sweetpete)\
**Post date:** [January 7, 2009, 7:34pm UTC](https://www.ruby-forum.com/t/after-update-element-and-text-field-with-auto-complete/157018/3 "2009-01-07T19:34:12Z")

</div>

Am I totally misunderstanding something here or…  
Please help! - I’m really stuck on this!
