Rails中的动态选择菜单/级联下拉? [英] Dynamic select menu / cascading drop down in Rails?

查看:247
本文介绍了Rails中的动态选择菜单/级联下拉?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以建议一个指南/教程,以使用最佳做法实现Rails中的动态选择菜单/级联下拉列表?或者可能最近的Stackoverflow问题围绕同一主题。可能我正在搜索错误的条款。



我已经看了这个轨道:#88动态选择菜单(修改),但我不相信使用csv文件存储选项是最好的方法



我发现有关下拉列表的其他内容似乎不完整或过时。

解决方案

或者您可能对此RESTful Rails 4解决方案感兴趣:使用Rails 4的动态选择框



基本上,从模型中填充选择框,控制器添加一个动作来选择相干子集的数据,并且通过AJAX请求刷新视图。


Could someone suggest a guide/tutorial for implementing a dynamic select menu / cascading drop down in Rails using best practices? Or possibly recent Stackoverflow questions around the same topic. Possibly I'm searching the wrong terms.

I've taken a look at this railscast: #88 Dynamic Select Menus (revised) but am not convinced using a csv file to store the options is the best way to go about this.

Everything else that I've found regarding dropdowns seems incomplete or outdated.

解决方案

Alternatively you might be interested in this RESTful Rails 4 solution: Dynamic select boxes with Rails 4.

Basically, the select boxes are populated from the model, the controller adds an action to pick the coherent subset of data, and the view is refreshed through an AJAX request.

这篇关于Rails中的动态选择菜单/级联下拉?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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