# Autocomplete with extra data

**URL:** <https://www.ruby-forum.com/t/autocomplete-with-extra-data/176973>\
**Category:** Rails\
**Created:** [October 9, 2009, 6:04am UTC](https://www.ruby-forum.com/t/autocomplete-with-extra-data/176973 "2009-10-09T06:04:57Z")\
**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:** [October 9, 2009, 6:04am UTC](https://www.ruby-forum.com/t/autocomplete-with-extra-data/176973/1 "2009-10-09T06:04:57Z")

</div>

I have the autocompleter using the :select =\> ‘NAME’ option.

This is the partial:

\<% @dt.each do |user| -%\>- \<%=h user[0] %\>
\<%= user[0] %\>

\<%= user[1] %\>
\<% end %\>

I am getting all of the data when I select the name. I have done this  
before but I am not sure why it is retrieving all of the data as the  
select option is supposed to only use the data in the class  
specified. any ideas?

---

<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 9, 2009, 10:33pm UTC](https://www.ruby-forum.com/t/autocomplete-with-extra-data/176973/2 "2009-10-09T22:33:03Z")

</div>

Wtf is this about?

2009/10/9, Me [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> \<%= user[0] %\>  
> select option is supposed to only use the data in the class  
> specified. any ideas?
> 
> >

–  
Von meinen Mobilgerät aus gesendet

---

<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 9, 2009, 10:41pm UTC](https://www.ruby-forum.com/t/autocomplete-with-extra-data/176973/3 "2009-10-09T22:41:15Z")

</div>

Ok here is the full code then.  
\<%= text\_field\_with\_auto\_complete :friend, :name,{:select =\> “NAME”},  
:after\_update\_element =\> “function(element,value){” +  
remote\_function(:url  
=\> { :controller =\> ‘followerranking’, :action =\> :ajax\_add\_friend },  
:with  
=\> “‘friend[name]=’ + element.value”) + “}” %\>

Partial for autocomplete drop down. The SELECT above is supposed to  
pick  
the element with the class specified. It is selected everything not  
only  
just the div witht he class name.

\<% @dt.each do |user| -%\>- \<%=h user[0] %\>
\<%= user[0] %\>

\<%= user[1] %\>
\<% end %\>

---

<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 10, 2009, 6:03pm UTC](https://www.ruby-forum.com/t/autocomplete-with-extra-data/176973/4 "2009-10-10T18:03:41Z")

</div>

Anybody? this behaves like the select statement is not even there for  
some reason.
