问题描述
在我的应用程序,有两种型号:询价和标准。他们的关系是多到多。在创建询价屏幕上,code下面显示可用列表中进行选择在下拉列表中:
In my app, there are two models: rfq and standard. Their relationship is many-to-many. In rfq creating screen, the code below displays a list of available for selection in drop down list:
<%= simple_form_for @rfq do |f| %>
<%= f.association :standards, :collection => Standard.active_std.all(:order => 'name'), :label_method => :name, :value_method => :id %>
<% end %>
的问题是,该列表是不折叠,这意味着有一个多线箱中显示的多个标准。我怎样才能盒子减少只有一条线?
The problem is that the list is not collapsed, which means there are multiple standards displayed in a multi-line boxes. How can I reduce the box to one line only?
感谢。
更新:这里是多行列表框的屏幕截图:
UPDATED: here is the screen shot of multiple line list box:
推荐答案
这是创造一个多选,因为一个询价可以有很多标准,所以它可以让你按住Ctrl键单击选择很多标准。
It's creating a multi-select because one rfq can have many standards, so it allows you to ctrl-click to select many standards.
您可以尝试添加:input_html =&GT; {:大小=&GT;'1'}
,但我不知道这种意志preserve滚动条。它绝对不会降下来了。
You could try adding :input_html => { :size =>'1' }
but I'm not sure that will preserve the scrollbar. It definitely won't drop down.
下面是别人谁想做同样的事情:HTML muliple选择应该像HTML选择。答案之一是指 jQuery中实现,但是这将需要一些工作与SimpleForm整合
Here's someone else who wanted to do the same thing: HTML muliple select should look like HTML select. One of the answers refers to a Dropdown Check List implemented in jQuery, but that would take some work to integrate with SimpleForm.
SimpleForm有一个非常有用的谷歌集团 - 你可能会得到更多的想法有:
SimpleForm has a very helpful Google Group--you might get more ideas there:
这篇关于如何在一个轨道collasped下拉列表simple_form的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!