Javascript rails按钮标签与按钮标签-类别和id
我正在尝试构建一个带有id的按钮和一个带有rails的类。单击按钮时会触发javascript事件。我尝试了不同的方法,但没有一个能成功Javascript rails按钮标签与按钮标签-类别和id,javascript,ruby-on-rails,Javascript,Ruby On Rails,我正在尝试构建一个带有id的按钮和一个带有rails的类。单击按钮时会触发javascript事件。我尝试了不同的方法,但没有一个能成功 <%= button_tag "Launch the js event", id: "button-feedback-by-bullet" %> 这是可行的,但没有课 <%= button_tag "Launch the js event", id: "button-feedback-by-bullet", class: "btn
<%= button_tag "Launch the js event", id: "button-feedback-by-bullet" %>
这是可行的,但没有课
<%= button_tag "Launch the js event", id: "button-feedback-by-bullet", class: "btn-primary" %>
我得到一个错误,说有太多的论点
<%= button_to "Launch the js event", id: "button-feedback-by-bullet", class: "btn-primary" %>
我得到了正确的类,但是按钮传递了一个post方法,js事件没有被触发
你能帮我找到正确的语法并理解button_tag和Butto之间的细微差别吗?谢谢
按钮\u tagcontent\u或\u options=nil、options=nil和block public
你应该这样做
<%= button_tag "Launch the js event", {id: "button-feedback-by-bullet", class: "btn-primary"} %>
此外,默认情况下,button_标记或button_to触发提交,也许您应该使用link_to
<%= button_to "Launch the js event", {}, {id: "button-feedback-by-bullet", class: "btn-primary"} %>