[Rails] text_field_with_auto_complete

Sébastien Gruhier seb at itseb.com
Fri Jan 20 18:17:32 GMT 2006


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 :

> 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
>
> On 1/20/06, Sébastien Gruhier <seb at itseb.com> wrote:
> 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
>
>
>
> _______________________________________________
> Rails mailing list
> Rails at lists.rubyonrails.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>
>
>
>
>
> -- 
> Ben Reubenstein
> http://www.benr75.com
> _______________________________________________
> Rails mailing list
> Rails at lists.rubyonrails.org
> http://lists.rubyonrails.org/mailman/listinfo/rails

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060120/de6759ca/attachment.html


More information about the Rails mailing list