简体   繁体   English

Ruby on Rails:如何向 submit_tag 添加确认

[英]Ruby on Rails: How do I add a confirmation to a submit_tag

<%= submit_tag "Delete" , :confirm => 'Are you sure you want to delete the selected?' %>

doesn't work.不起作用。

how do I do this?我该怎么做呢?

It should work. 它应该工作。 Most likely you didn't include necessary JavaScript files. 您很可能没有包括必要的JavaScript文件。 Do you have something like this in your HTML head tag? 您的HTML head标签中是否有类似的内容?

<%= javascript_include_tag :defaults %>

尝试这个 :

<%= submit_tag "Delete", data: { confirm: 'Are you sure you want to delete the selected?' }%>

I found this solution and it works to me.我找到了这个解决方案,它对我有用。

<%= submit_tag 'Save', onclick: "return confirm('Are you sure?')" %>

The Solution link is Here解决方案链接在这里

Thanks谢谢

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM