I have ajax.autocompleter working and I can get the string entered into the field from the list. But how do I view that selected text with the 'show' method? Here is my code:
----- Controller -------- def autocomplete search = params[:user] @users = User.find(:all, :conditions => [ 'LOWER(first_name) LIKE ? OR LOWER(last_name) LIKE ?', "%#{search.downcase}%", "%#{search.downcase}%" ], :order => 'first_name, last_name DESC', :limit => 8) unless search.blank? render :partial => "search" end
------ autocompleter -------- <%= javascript_tag("new Ajax.Autocompleter('user', 'user_results', '/autocomplete', {indicator: 'spinner', frequency: 0, minChars: 1, } );") -%>
------- search partial ---------- <ul class="autocomplete_list"> <% for user in @users do -%> <li class="autocomplete_item"> <div class="name"><%= link_to user.whole_name, user_path(user) %></
</li> <% end -%> </ul>
From what I've read I think I need to use the updateAfterElement
option but I don't exactly know how. When the text is selected from the list, I'd like it to invoke the 'show' medthod resulting in a url like: http://domain.com/users/1
Thanks for any help!