# Qustion about autocomplete

**URL:** <https://www.ruby-forum.com/t/qustion-about-autocomplete/123248>\
**Category:** Rails\
**Created:** [December 15, 2007, 12:05pm UTC](https://www.ruby-forum.com/t/qustion-about-autocomplete/123248 "2007-12-15T12:05:38Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![laurent](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/ce7236/32.png) [@laurent](https://www.ruby-forum.com/u/laurent)\
**Post date:** [December 15, 2007, 12:05pm UTC](https://www.ruby-forum.com/t/qustion-about-autocomplete/123248/1 "2007-12-15T12:05:38Z")

</div>

Hi

In a Rails application i use text\_with\_autocomplete helper.  
My problem is in a Compose Message page :  
Imagine a textfield, where i should type my email adresses : i can  
type many emails separated by colon.

- in the view : \<%=text\_field\_with\_auto\_complete(“message”, “to”,  
{:size =\>90}, :skip\_style =\> true) %\>
- My controller action splits the received string that could be  
‘removed\_email\_address@domain.invalid, yo’ , and does the search on the last string ‘yo’
- The partial to show the list woould be then :

- removed\_email\_address@domain.invalid
- removed\_email\_address@domain.invalid

My problem is now to append/replace in my text field the current value  
before autocompletion ( ‘removed\_email\_address@domain.invalid, yo’ ) by :  
Imagine the selected value from the drop down list is  
‘removed\_email\_address@domain.invalid’  
I’d like to split the textfield value, and replace the second string  
‘yo’ by ‘removed\_email\_address@domain.invalid’, to have as a final result in the  
textfield : ‘removed\_email\_address@domain.invalid, removed\_email\_address@domain.invalid’

I tried :before\_update\_element but that doesn’t work

Any help would be appreciated

---

<div class="post-metadata">

**Author:** ![laurent](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/ce7236/32.png) [@laurent](https://www.ruby-forum.com/u/laurent)\
**Post date:** [December 15, 2007, 12:16pm UTC](https://www.ruby-forum.com/t/qustion-about-autocomplete/123248/2 "2007-12-15T12:16:48Z")

</div>

On Dec 15, 2007, at 12:04 PM, Laurent wrote:

> In a Rails application i use text\_with\_autocomplete helper.  
> My problem is in a Compose Message page :  
> Imagine a textfield, where i should type my email adresses : i can  
> type many emails separated by colon.
> 
> - in the view : \<%=text\_field\_with\_auto\_complete(“message”, “to”,  
> {:size =\>90}, :skip\_style =\> true) %\>

Have a look at the :tokens option, see page 545 of the Agile.

– fxn

---

<div class="post-metadata">

**Author:** ![laurent](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/ce7236/32.png) [@laurent](https://www.ruby-forum.com/u/laurent)\
**Post date:** [December 15, 2007, 1:56pm UTC](https://www.ruby-forum.com/t/qustion-about-autocomplete/123248/3 "2007-12-15T13:56:24Z")

</div>

Ok fine it works… i didn’t remember it was supported… Thanks for  
the pointer in the book…
