admin管理员组文章数量:1332604
This is probably a very simple question, but I can't find the answer, so hopefully someone can help?
How do you cancel a click action if the user clicks 'cancel' in a confirm box?
I have this so far but can't find what I need to fill in the blank.
jQuery('#doaction').click(function(e){
if(jQuery('#bulk-action-selection').val() === 'delete'){
var action = confirm('Are you sure you wish to delete the selected User Groups? This action cannot be undone.');
}
if(action === false){
{ Cancel the click and don't delete the items }
}
});
This is probably a very simple question, but I can't find the answer, so hopefully someone can help?
How do you cancel a click action if the user clicks 'cancel' in a confirm box?
I have this so far but can't find what I need to fill in the blank.
jQuery('#doaction').click(function(e){
if(jQuery('#bulk-action-selection').val() === 'delete'){
var action = confirm('Are you sure you wish to delete the selected User Groups? This action cannot be undone.');
}
if(action === false){
{ Cancel the click and don't delete the items }
}
});
Share
Improve this question
edited Feb 29, 2012 at 11:11
Lightness Races in Orbit
385k77 gold badges666 silver badges1.1k bronze badges
asked Dec 22, 2011 at 9:46
David GardDavid Gard
12.1k42 gold badges128 silver badges261 bronze badges
1
- 1 If user press cancel just don't do anything? – matino Commented Dec 22, 2011 at 9:49
3 Answers
Reset to default 4 if( action === false )
return false;
This should work.
Try this:
jQuery('#doaction').click(function(e){
if(jQuery('#bulk-action-selection').val() === 'delete'){
var action = confirm('Are you sure you wish to delete the selected User Groups? This action cannot be undone.');
if(action === false) {
return false; // this would do
}
}
});
Wont this work:
jQuery('#doaction').click(function(e){ if(jQuery('#bulk-action-selection').val() === 'delete'){ var action = confirm('Are you sure you wish to delete the selected User Groups? This action cannot be undone.'); } else { return false; } });
本文标签: javascriptCancel a user click on confirm box 39cancel39Stack Overflow
版权声明:本文标题:javascript - Cancel a user click on confirm box 'cancel' - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742269432a2444024.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论