3

I am using this gem:

https://github.com/crowdint/rails3-jquery-autocomplete

I am having difficulty making the auto-complete work and also to create a simple search. This is what I have in the view:

 16     - semantic_form_for vendors_path do |f| 
 17       - f.autocompleted_input :name, :url => autocomplete_vendor_name_home_index_path 

The url isn't making sense to me.

Here is the output HTML:

<input data-autocomplete="/home/autocomplete_vendor_name" id="_vendors_name" name="/vendors[name]" required="required" size="30" type="text" class="ui-autocomplete-input" autocomplete="off" role="textbox" aria-autocomplete="list" aria-haspopup="true">

And I don't want to create a new vendor, I want to submit a search...but first am trying to get the autocomplete to work.

Suggestions?

Satchel
  • 16,414
  • 23
  • 106
  • 192

2 Answers2

2

An example from one of my projects:

routes.rb: get 'users/autocomplete_category_name'

view:

<%= form_tag 'users/index' do %>
  <%= autocomplete_field_tag 'name', '', users_autocomplete_category_name_path, :size => 75 %>
<% end %>
Markus Proske
  • 3,356
  • 3
  • 24
  • 32
  • this is helpful, I guess I am trying to understand what it's trying to do, for example, is the route where the controller is displaying the autcomplete or is it the model? Seems like from the documentation it is the controller.... – Satchel May 06 '11 at 14:44
  • The example I took the code of was just a quick JQuery test with a user model and a users controller. – Markus Proske May 06 '11 at 22:47
  • okay I think this works if I went it to send to a search controller, I would put it and the action right after form_tag? – Satchel May 14 '11 at 18:12
  • Sorry Angela, I don't understand the question here. However, I do not have much experience with this jquery autocomplete gem, just tried out and decided not to use it... – Markus Proske May 15 '11 at 09:00
2

If your not tied to using jQuery-autocomplete, you might be better off trying 'TokenInput' instead, I think it's alot nicer to use and there is also a railscast on it which is always handy :)

http://railscasts.com/episodes/258-token-fields

Hope this helps.

David Barlow
  • 4,914
  • 1
  • 28
  • 24