DDD*_*DDD 2 ruby-on-rails twitter-bootstrap ruby-on-rails-4
Ruby on Rails 4.
我安装gem 'country_select', '~> 1.3.1'
并让下拉工作有点奇怪.我找不到有关向该字段添加样式类的文档.
我需要在JS中使用的id,我试图在字段中使用Bootstrap类.任何下拉类都会很好:
<%= f.label :ship_country, "Country:" %><br>
<%= f.country_select :ship_country, {class: "dropdown", :id => "payment_ship_country"} %>
Run Code Online (Sandbox Code Playgroud)
这显示了一个丑陋的默认选择类,它还添加了"class"和"id"作为选择选项,因此语法明显偏离.有任何想法吗?
class
并且id
是html
选项,它们应该作为country_select
方法的第三个参数传递.第二个参数是要在下拉列表中显示的选项列表,这就是您在下拉列表中看到id
和class
作为可选选项而不是作为html选项应用的原因.
您可以执行以下操作:
<%= f.country_select :ship_country, {}, {class: "dropdown", :id => "payment_ship_country"} %>
Run Code Online (Sandbox Code Playgroud)
供您参考,请参阅以下country_select
文档中的示例:
Supplying additional html options:
country_select("user", "country", { priority_countries: ["GB", "FR"] }, { selected: "GB", class: 'form-control' })
Run Code Online (Sandbox Code Playgroud)
这应该在这里工作:
<%= f.country_select :ship_country, priority_countries = ["United States"], options = {}, html_options = {:class => "input-lg", :id => "payment_country"} %>
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
1281 次 |
最近记录: |