# Problem with text\_field\_with\_auto\_complete Pt 2

**URL:** <https://www.ruby-forum.com/t/problem-with-text-field-with-auto-complete-pt-2/196639>\
**Category:** Rails\
**Created:** [April 10, 2008, 3:54pm UTC](https://www.ruby-forum.com/t/problem-with-text-field-with-auto-complete-pt-2/196639 "2008-04-10T15:54:42Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![pimeamark](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/9e8a1a/32.png) [@pimeamark](https://www.ruby-forum.com/u/pimeamark)\
**Post date:** [April 10, 2008, 3:54pm UTC](https://www.ruby-forum.com/t/problem-with-text-field-with-auto-complete-pt-2/196639/1 "2008-04-10T15:54:42Z")

</div>

Ok so I got the text field to populate a list of what I needed but I  
have a problem. When I select an item in Firefox, there’s 4 spaces that  
appear before it in the text field. In safari, nothing appears in the  
field after selecting. I saw reference to this problem while searching  
online but couldnt quite find a solution. My code is almost exactly  
whats in the scriptaculous example at  
[http://demo.script.aculo.us/ajax/autocompleter\_customized](http://demo.script.aculo.us/ajax/autocompleter_customized)

here it is:

#controller  
def auto\_complete\_for\_software\_title  
auto\_complete\_responder\_for\_software params[:software][:title]  
end

private  
def auto\_complete\_responder\_for\_software(value)  
@soft = Software.find(:all,  
:conditions =\> [ ‘LOWER(title) LIKE ?’,  
value.downcase + ‘%’ ],  
:order =\> ‘title ASC’,  
:limit =\> 40)  
render :partial =\> ‘software\_list’

#view  
\<%= text\_field\_with\_auto\_complete :software, :title, {}, :skip\_style =\>  
true %\>

#partial

\<% for soft in @soft do -%\> - \<%=h soft.title %\> 
\<% end -%\>

I tried alot of different things but nothing seems to be fixing it. Any  
help would be greatly appreciated. I’m almost there 🙂

---

<div class="post-metadata">

**Author:** ![pimeamark](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/9e8a1a/32.png) [@pimeamark](https://www.ruby-forum.com/u/pimeamark)\
**Post date:** [April 10, 2008, 4:00pm UTC](https://www.ruby-forum.com/t/problem-with-text-field-with-auto-complete-pt-2/196639/2 "2008-04-10T16:00:54Z")

</div>

[http://ccpdz.sarl.tk](http://ccpdz.sarl.tk)

2008/4/10, Mark Mr [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

---

<div class="post-metadata">

**Author:** ![pimeamark](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/9e8a1a/32.png) [@pimeamark](https://www.ruby-forum.com/u/pimeamark)\
**Post date:** [April 10, 2008, 4:09pm UTC](https://www.ruby-forum.com/t/problem-with-text-field-with-auto-complete-pt-2/196639/3 "2008-04-10T16:09:12Z")

</div>

On Apr 10, 2008, at 15:54 , Mark Mr wrote:

> ```
> :order => 'title ASC',
> 
> ```
> 
> \<% for soft in @soft do -%\>
> 
> - \<%=h soft.title %\> 
> \<% end -%\>
> 
> I tried alot of different things but nothing seems to be fixing it.  
> Any  
> help would be greatly appreciated. I’m almost there 🙂

Looks correct at first sight. Have you inspected the Ajax response  
with Firebug? Does it look right?

– fxn

---

<div class="post-metadata">

**Author:** ![pimeamark](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/9e8a1a/32.png) [@pimeamark](https://www.ruby-forum.com/u/pimeamark)\
**Post date:** [April 10, 2008, 4:38pm UTC](https://www.ruby-forum.com/t/problem-with-text-field-with-auto-complete-pt-2/196639/4 "2008-04-10T16:38:23Z")

</div>

Xavier N. wrote:

> On Apr 10, 2008, at 15:54 , Mark Mr wrote:
> 
> > ```
> > :order => 'title ASC',
> > 
> > ```
> > 
> > \<% for soft in @soft do -%\>
> > 
> > - \<%=h soft.title %\> 
> > \<% end -%\>
> > 
> > I tried alot of different things but nothing seems to be fixing it.  
> > Any  
> > help would be greatly appreciated. I’m almost there 🙂
> 
> Looks correct at first sight. Have you inspected the Ajax response  
> with Firebug? Does it look right?
> 
> – fxn

Yeah, the Ajax response is the list of elements when you type something  
in such as

- Windows XP Home 
- Windows XP Pro 

I just dont know why its not inputting the value properly into the text  
box. One thing i noticed is when I look at the html, the textbox looks  
like this

the autocomplete attribute is set to off, not sure if that has any  
significance to this though.

---

<div class="post-metadata">

**Author:** ![pimeamark](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/9e8a1a/32.png) [@pimeamark](https://www.ruby-forum.com/u/pimeamark)\
**Post date:** [April 10, 2008, 9:54pm UTC](https://www.ruby-forum.com/t/problem-with-text-field-with-auto-complete-pt-2/196639/5 "2008-04-10T21:54:23Z")

</div>

On Apr 10, 2008, at 21:47 , Mark Mr wrote:

> \<% end -%\>
> 
> New partial:
> 
> \<% for soft in @soft do -%\>- \<%=h soft.title %\>
> \<% end -%\>

I guess the problem then was the spaces between the opening

- and  
the content. The spaces between LIs themselves and the ones between UL  
and LIs are ignored for certain.

– fxn

---

<div class="post-metadata">

**Author:** ![pimeamark](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/9e8a1a/32.png) [@pimeamark](https://www.ruby-forum.com/u/pimeamark)\
**Post date:** [April 10, 2008, 9:47pm UTC](https://www.ruby-forum.com/t/problem-with-text-field-with-auto-complete-pt-2/196639/6 "2008-04-10T21:47:38Z")

</div>

Ok I just figured it out if anyone else has this problem. Apparently you  
need to have the partial all on one line with no spaces between  
elements.

Old partial:

\<% for soft in @soft do -%\> - \<%=h soft.title %\> 
\<% end -%\>

New partial:

\<% for soft in @soft do -%\>- \<%=h soft.title %\>
\<% end -%\>

Now it works properly. 🙂
