Forum: Ruby on Rails text_field_with_auto_complete

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Ceee1f15591d1f61ac5bec1bc70d0062?d=identicon&s=25 Sébastien Gruhier (Guest)
on 2006-01-20 17:41
(Received via mailing list)
Hi,

I am trying to use text_field_with_auto_complete, it works fine but
when I click on an item (even if I use the up and down key and then
type enter) th search panel disappears but the selected results is
not shown in the text field. Even more, the text field becomes empty.

Any idea?

Thanks

Sébastien
D90ef6808433e63203e15a5c2dadb0bb?d=identicon&s=25 Ben Reubenstien (Guest)
on 2006-01-20 19:42
(Received via mailing list)
Hi Sebastien ~

What does your view look like? ~ What does your Controller method have
to
handle the request? ~ What browser are you working in?

Right now it is tough to offer a reason why this isn't working without
some
more information.

~ Ben
Ceee1f15591d1f61ac5bec1bc70d0062?d=identicon&s=25 Sébastien Gruhier (Guest)
on 2006-01-20 19:57
(Received via mailing list)
Sorry, I was not very precise

I am on Max OS X - Safari
It's a simple search for people using their lastname. What will be
perfect is when I click on a name from the result list, I go to the
update page.


** view
<%= text_field_with_auto_complete :search, :name, { :auto_complete =>
"off" }, :skip_style => true  %>

** controller
def auto_complete_for_search_name
	search = params[:search][:name]
	@citizens = Citizen.find(	:all, :conditions => [ 'LOWER(lastname)
LIKE ?','%' + search.downcase + '%' ], :order => 'lastname
ASC', :limit => 15)
	render :partial => 'found'
end

** partial html
<ul class="search">
   <% for citizen in @citizens.to_a -%>
     <li class="search">
   	  <div class="name"><%=h citizen.lastname %></div>
	</li>
   <% end -%>
</ul>


Thanks
Sébastien

Le 20 janv. 06 à 19:03, Ben Reubenstien a écrit :
74105552be623562f5da32b6e93997ac?d=identicon&s=25 Cagan Senturk (cagan327)
on 2006-07-11 16:32
hi Sebastien,
I am having the exact same problem. Where you able to figure this one
out?
Thanks,
Cagan

Sébastien Gruhier wrote:
> Sorry, I was not very precise
>
> I am on Max OS X - Safari
> It's a simple search for people using their lastname. What will be
> perfect is when I click on a name from the result list, I go to the
> update page.
>
>
> ** view
> <%= text_field_with_auto_complete :search, :name, { :auto_complete =>
> "off" }, :skip_style => true  %>
>
> ** controller
> def auto_complete_for_search_name
> 	search = params[:search][:name]
> 	@citizens = Citizen.find(	:all, :conditions => [ 'LOWER(lastname)
> LIKE ?','%' + search.downcase + '%' ], :order => 'lastname
> ASC', :limit => 15)
> 	render :partial => 'found'
> end
>
> ** partial html
> <ul class="search">
>    <% for citizen in @citizens.to_a -%>
>      <li class="search">
>    	  <div class="name"><%=h citizen.lastname %></div>
> 	</li>
>    <% end -%>
> </ul>
>
>
> Thanks
> Sébastien
>
> Le 20 janv. 06 à 19:03, Ben Reubenstien a écrit :
This topic is locked and can not be replied to.