【问题标题】:input type = button access link_to输入类型=按钮访问link_to
【发布时间】:2012-10-23 08:45:05
【问题描述】:

我有以下haml代码

%input{type: "button", value: "Finish"}= link_to "", stop_time_entry_path(time_entry), remote: true

单击按钮时如何访问 stop_time_entries_path(time_entry)?

看起来很简单,但我想不通

【问题讨论】:

  • 为什么用html标记?此问题中没有 HTML。
  • haml 和 html 的唯一区别是语法。
  • 什么?所以我得到了上面这样的汤,而不是干净的标记?

标签: html ruby-on-rails haml


【解决方案1】:
= link_to stop_time_entry_path(time_entry), remote: true do
    %input{type: "button", value: "Finish"}

这就是解决方案。

【讨论】:

    【解决方案2】:

    有一个button_to Rails 助手。试试看:

    button_to "Finish", stop_time_entries_path(time_entry), remote: true

    【讨论】:

    • 我需要类型为 "button" 而不是 "submit" 。所以它不起作用:(
    猜你喜欢
    • 1970-01-01
    • 2015-06-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-08-07
    • 2019-01-23
    相关资源
    最近更新 更多