开发者

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

开发者 https://www.devze.com 2023-01-07 07:32 出处:网络
<%= submit_tag \"Delete\" , :confirm => \'Are y开发者_运维百科ou sure you want to delete the selected?\' %>
<%= submit_tag "Delete" , :confirm => 'Are y开发者_运维百科ou sure you want to delete the selected?' %>

doesn't work.

how do I do this?


Try this :

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


It should work. Most likely you didn't include necessary JavaScript files. Do you have something like this in your HTML head tag?

<%= javascript_include_tag :defaults %>


I found this solution and it works to me.

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

The Solution link is Here

Thanks

0

精彩评论

暂无评论...
验证码 换一张
取 消