【问题标题】:Add class to Button_to in Active Admin在 Active Admin 中将类添加到 Button_to
【发布时间】:2014-07-14 10:29:27
【问题描述】:

在 Rails 4 中,我试图在 Active Admin Dashboard 上的循环内向按钮添加一个 CSS 类,例如 button_to "Block", action: :block_cars, controller: :companies, id: company

但这似乎不起作用:

button_to "Block", :class => 'dangerbtn', action: :block_cars, controller: :companies, id: company

任何帮助将不胜感激,谢谢。

【问题讨论】:

    标签: css ruby-on-rails-4 activeadmin erb


    【解决方案1】:

    class 是一个 HTML 选项,但您在选项哈希中有它。试试这样吧:

    button_to "Block", {action: :block_cars, controller: :companies, id: company}, {:class => 'dangerbtn'}
    

    button_to 的格式为:

    button_to(name = nil, options = nil, html_options = nil, &block)
    

    更多详情请见the API

    【讨论】:

    • 没问题。乐于助人:)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-07-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-05-15
    • 1970-01-01
    相关资源
    最近更新 更多