开发者

Google suggest and auto complete with jquery/ajax in Rails app

I would like to get some ref to use Jquery in Rails app. At 开发者_运维知识库the moment, I am stuck to find the things to enable google suggest in text box and autocomplete in Rails app. Any help/suggestions/ref would be of great help.


I did a short search on auto-complete with Rails earlier today and these are the best links I found:

  • http://github.com/crowdint/rails3-jquery-autocomplete and http://github.com/crowdint/rails3-jquery-autocomplete-app
  • http://blog.jackhq.com/posts/3-how-to-add-jquery-autocomplete-to-your-rails-forms-in-a-restful-way
  • http://code.google.com/p/jquery-autocomplete/

Edit: I just implemented the first link in my app, works flawless so far. I had minor problems with the documentation though, this works for me (on typing AutoComplete starts after the second character):

Model named Category, has an attribute name:

controller:

class UsersController < ApplicationController
  autocomplete :category, :name
  ...

routes:

get 'users/autocomplete_category_name'

view:

<%= form_tag 'users/index' do %>
  <%= autocomplete_field_tag 'address', '', users_autocomplete_category_name_path, :size => 75 %>
<% end %>
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜