Forum: Ruby on Rails text_field_with_auto_complete() - problem

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Cb816e71c90750565675cf63233d4db1?d=identicon&s=25 Christian Rolle (chrishawaii)
on 2007-01-11 16:05
hello rubys,

i got a problem with the text_field_with_auto_complete().
everthing's working but unfortunately the items (which are for choosing)
are filled into the input=text in a way that is unacceptable.
the first 6 characzers are empty-spaces, than the item and at last 5
doeas anybody know why? and maybe how to solve this problem?
my code is following:
<td><%= text_field_with_auto_complete(:vorgang, :bez, {:class =>
'auto_complete_schmal'}, {:skip_style => true} ) %></td>

def auto_complete_for_vorgang_bez()
    search = params[:vorgang][:bez].downcase # content of the text-field
    search = '%' + search + '%' # format string for request
    conditions = ['(LOWER(bez) LIKE ?)', search] # sql
    @vorgaenge = Vorgang.find(:all, :conditions => conditions, :limit =>
1) # request
    render(:partial => 'vorgang_filter_select') # rendering in

please give me an hint. i'm thankful for every helping answer.

Cb816e71c90750565675cf63233d4db1?d=identicon&s=25 Christian Rolle (chrishawaii)
on 2007-01-14 11:52
i solved it by myself.
this link is very helpful:

the answer which belongs to the sixth question is the key.

Cd1de7e6a1ff7903b249edc2a4a35b34?d=identicon&s=25 gaurav bagga (Guest)
on 2007-01-19 16:31
(Received via mailing list)

 I also faced the problem of appended whitespaces, I did a fix in
controls.js of scriptaculous
by writting

 this.element.value = (value.replace(/^\W+/,'')).replace(/\W+$/,'');

you will find this around line 250..260

hope this helps

This topic is locked and can not be replied to.