我有一个表,其中每一行都有一个带有此表单的删除按钮
<form id="tableDelete_1">
<input type="hidden" name="tipo" value="delete" />
<input type="submit" name="send" value="Delete" class="btn btn-danger btn-xs" onClick="return confirm(`Are you sure?`)" />
</form>
<form id="tableDelete_2">
<input type="hidden" name="tipo" value="delete" />
<input type="submit" name="send" value="Delete" class="btn btn-danger btn-xs" onClick="return confirm(`Are you sure?`)" />
</form>
然后这个在页面底部
$(document).on('submit', '[id^=tableDelete_]' , function() {
return callAjax( $(this).serialize() );
});
function callAjax( data ) {
$.ajax({
type : 'POST',
url : 'call/page.php',
data : data,
success : function(data) { ... },
error: function(data) { ... }
});
return false;
};
现在我要删除经典
onClick="return confirm(`Are you sure?`)"
并使用 sweetalert ……当我只想显示具有此功能的弹出窗口时,我刚开始时遇到问题
$(document).on('submit', '[id^=tableDelete_]' , function() {
swal({
title: "Are you sure?",
text: "You will not be able to recover this imaginary file!",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "Yes, delete it!",
closeOnConfirm: false
},
function(){
swal("Deleted!", "Your imaginary file has been deleted.", "success");
});
};
弹出窗口仅显示一秒钟,然后重新加载页面,因为我认为表单已提交…
请给我帮助
原文由 FireFoxII 发布,翻译遵循 CC BY-SA 4.0 许可协议
如果我没看错的话,我想你正在寻找这样的东西?