【问题标题】:haml/html dropdown as a table column作为表格列的haml/html 下拉列表
【发布时间】:2013-11-20 10:03:38
【问题描述】:

我正在显示一个表格,其中一列是一个下拉列表,它也改变了行的状态

for ex:
    %table#bug.table
      %thead
        %tr
          %th.span3 bug name
          %th.span6 Comment
          %th.span2 State
          %th.span2 Manage

      %tbody
        - @bug.each do |ref|
          %tr
            %td= bug.name
            %td= bug.comment
            %td= bug.state
            %td= select(bug.state_events)

上面,bug.state_events 在下拉列表中返回该错误的下一个可能状态。然后,用户可以更改状态(比如说从打开固定)。

在 haml/html 中实现此功能的最佳方法是什么?

PS: 我正在使用 Rails、haml、state_machine gems

【问题讨论】:

    标签: html ruby-on-rails user-interface drop-down-menu haml


    【解决方案1】:

    试试这个

    = select_tag "tag_name", options_from_collection_for_select(bug.state_events, "id", "name"),{ :prompt => "Select State"}
    

    【讨论】:

    • 感谢@Sabyasachi,这个 options_for_select 对我有用! .因为这是一个表而不是一个表单,我想知道是否有任何帮助器等可以让用户通过使用下拉列表来更改数据库中错误的状态,并获取要在下拉列表中显示的新状态?
    • @codeObserver 我猜没有这样的助手,但是您可以通过在后台调用 ajax 方法来更改下拉值来轻松实现它
    猜你喜欢
    • 1970-01-01
    • 2011-12-06
    • 1970-01-01
    • 1970-01-01
    • 2015-07-23
    • 1970-01-01
    • 2016-04-04
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多