admin管理员组文章数量:1305179
I have a form with a submit_tag
.
I want both to set the content value and have a js popup confirming the intent.
I've tried the suggestion in this answer and what the docs describe.
Neither of the below invoke the confirmation dialog, but it does for a link_to
tag. What am I doing wrong?
f.submit "Do this", data: {confirm: 'Are you sure?'}
f.submit "Do this", confirm: 'Are you sure?'
f.submit confirm: 'Are you sure?'
I have a form with a submit_tag
.
I want both to set the content value and have a js popup confirming the intent.
I've tried the suggestion in this answer and what the docs describe.
Neither of the below invoke the confirmation dialog, but it does for a link_to
tag. What am I doing wrong?
f.submit "Do this", data: {confirm: 'Are you sure?'}
f.submit "Do this", confirm: 'Are you sure?'
f.submit confirm: 'Are you sure?'
Share
Improve this question
edited May 23, 2017 at 11:47
CommunityBot
11 silver badge
asked Jan 17, 2014 at 7:01
Fellow StrangerFellow Stranger
34.1k37 gold badges178 silver badges249 bronze badges
1 Answer
Reset to default 11Add this onsubmit
function to your form helper
<%= form_for(... , html: {:onsubmit => "return confirm('Are you sure?');" }) do |f| %>
If you have jQuery
and want to do it un-obstructively, you can do inside of document ready
$('#my-form').submit(function() {
return confirm('Are you sure?');
})
本文标签: javascriptAdd confirm quotSurequot to fsubmitStack Overflow
版权声明:本文标题:javascript - Add confirm: "Sure?" to f.submit - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741783587a2397451.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论