简体   繁体   English

如何在Ruby on Rails中实现下拉选择窗口

[英]How to achieve drop down selection window in Ruby on Rails

I want to achieve a selection box in the drop down window.(I'm using something like 我想在下拉窗口中实现一个选择框。(我正在使用类似

<%= f.select(:season, options_for_select(['spring/fall', 'winter', 'summer'], 'spring/fall'))%>

for the selection box for now) 现在的选择框)

In this window, I want to have many icons. 在此窗口中,我想有很多图标。 The user can select one of these icons. 用户可以选择这些图标之一。 And the selected icon will be saved in the database as one attribute of the object. 所选图标将作为对象的一个​​属性保存在数据库中。

Can I do this without JavaScript? 没有JavaScript我可以做到吗?

Yes it is possible to use the background-image property to set icons in a dropdown, but apparently it only works in Firefox 是的,可以使用background-image属性在下拉菜单中设置图标,但是显然它仅在Firefox中有效

See this question for discussions of how to do it with JS putting images with options in a dropdown list 有关如何使用JS进行处理的讨论,请参阅此问题,有关将带选项的图像放入下拉列表的讨论

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM