【问题标题】:Rails, select helper, adding styleRails,选择助手,添加样式
【发布时间】:2010-02-20 10:52:59
【问题描述】:

我正在尝试做这样的事情。

 select :model, :attribute, :style => "some:style;" 

将style 添加到rails 中的select helper,但它不起作用。

【问题讨论】:

  • 这是一个非常严肃的问题,我一直在努力寻找答案,值得一票。

标签: ruby-on-rails


【解决方案1】:

来自documenation:

select(object, method, choices, options = {}, html_options = {})

所以你的:style 哈希需要是第五个参数。例如:

select(:model, :attribute, @options_for_select, { }, { :style => 'some: style' }

【讨论】:

  • 任何你想要的。最后一个参数只是在 select 元素上创建 HTML 属性,所以像这样的哈希:{ :class => 'myclass', :style => 'display: inline;' } 将创建:<select class="myclass" style="display: inline;">...</select>
  • 如何让它响应我的意思是..我希望我的选择标签获得所选值长度的宽度..任何人都可以提出一些建议
猜你喜欢
  • 2012-04-01
  • 1970-01-01
  • 2023-03-22
  • 1970-01-01
  • 2013-05-18
  • 1970-01-01
  • 2015-08-22
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多