开发者

How do I create an autocomplete search form in rails 3 using rails3-jquery-autocomplete?

开发者 https://www.devze.com 2023-03-03 13:55 出处:网络
I am using this gem: https://github.com/crowdint/rails3-jquery-au开发者_JAVA技巧tocomplete I am having difficulty making the auto-complete work and also to create a simple search.This is what I have

I am using this gem:

https://github.com/crowdint/rails3-jquery-au开发者_JAVA技巧tocomplete

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?


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 %>


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消