Google 建议并在 Rails 应用程序中使用 jquery/ajax 自动完成

发布于 2024-10-31 17:34:29 字数 99 浏览 7 评论 0原文

我想获得一些在 Rails 应用程序中使用 Jquery 的参考。 目前,我一直在寻找在文本框中启用谷歌建议和在Rails应用程序中自动完成的东西。任何帮助/建议/参考都会有很大帮助。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

慕巷 2024-11-07 17:34:29

今天早些时候,我对 Rails 的自动完成功能进行了简短搜索,这些是我找到的最佳链接:

编辑:我刚刚在我的应用程序中实现了第一个链接,到目前为止工作完美。不过,我在文档方面遇到了一些小问题,这对我有用(在第二个字符后键入 AutoComplete 时):

名为 Category 的模型,有一个属性名称:

控制器:

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

路由:

get 'users/autocomplete_category_name'

视图:

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

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

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 %>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文