Rails 3.2.8的可搜索下拉列表? [英] Searchable drop down list for rails 3.2.8?

查看:98
本文介绍了Rails 3.2.8的可搜索下拉列表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在新订单表单上,用户需要从包含数十个客户的下拉列表中选择一个客户,并且很难通过上下滚动来查找和选择.这就是为什么我们要构建一个可搜索的drop down list的原因.当用户输入几个客户名称字母时,下拉列表将过滤掉所有其他字母,只留下包含刚键入字母的客户名称.我们使用的是simple_formrails 3.2.8.我们可以做的一种方法是添加text box来输入搜索字符串,然后调用ajax来相应地加载下拉列表.这需要附加的文本字段,该文本字段是多余的.用户是否可以直接在下拉框中键入任何解决方案,然后列表会相应地过滤出来?谢谢.

On new order form, a user needs to select a customer from a drop down list which contains dozens of customers and is hard to find and select by scrolling up and down. That's why we want to build a searchable drop down list. When a user enter a few letters of customer's name, the drop down list filters out all others and is left with only the names of the customers containing the letters just keyed in. We are using simple_form and rails 3.2.8. One way we can do is to add a text box for entering search string and call ajax to load the drop down list accordingly. This requires additional text field which is redundant. Is there any solution which a user can directly type in drop down box and the list filters out accordingly? Thanks.

推荐答案

看看JQuery UI自动完成组合框.它提供了下拉功能以及搜索(自动完成)功能.使用simple_form应该可以正常工作.

Take a look at the JQuery UI autocomplete combobox. It provides both drop down functionality as well as search (autocomplete) functionality. It should work just fine with simple_form.

http://jqueryui.com/autocomplete/#combobox

我发现实现的最佳示例是: http://babinho.net/2011/05/autocomplete-fields-in-rails-3-1-with-jquery-ui/

The best example i've found of implementation is: http://babinho.net/2011/05/autocomplete-fields-in-rails-3-1-with-jquery-ui/

这篇关于Rails 3.2.8的可搜索下拉列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆