我试图使用甜蜜警报库发出警报。我试图集成用于为删除项发出确认警报的代码,但当我单击要删除该项的按钮时,这些代码不起作用。没有显示对话框。
在集成Sweet之前编写代码:
$(".delete-link").click(function() {
var id = $(this).attr("id");
var del_id = id;
var parent = $(this).parent("td").parent("tr");
if (confirm('Sure to Delete ID no = ' + del_id)) {
$.post('delete.php', { 'del_id': del_id }, function(data) {
parent.fadeOut('slow');
});
}
return false;
});集成Sweet后的代码:
$(".delete-link").click(function() {
var id = $(this).attr("id");
var del_id = id;
var parent = $(this).parent("td").parent("tr");
});
swal({
title: "Are you sure you want to delete?",
text: "Sure to Delete ID no = " + del_id,
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "Yes",
closeOnConfirm: false
},
function() {
$.post('delete.php', { 'del_id': del_id }, function(data) {
parent.fadeOut('slow');
});
});
return false;
});发布于 2017-04-30 18:29:36
我认为您的代码中有语法错误。试试这个,看看它是否有效--我还没有在我这一边测试代码。如果不起作用,请告诉我
$(".delete-link").click(function() {
var id = $(this).attr("id");
var del_id = id;
var parent = $(this).parent("td").parent("tr");
swal({
title: "Are you sure you want to delete?",
text: "Sure to Delete ID no = " + del_id,
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "Yes",
cancelButtonText: "No",
closeOnConfirm: true,
closeOnCancel: true
}, function(isConfirm) {
$.post('delete.php', {'del_id':del_id}, function(data) {
parent.fadeOut('slow');
});
});
return false;
});https://stackoverflow.com/questions/43709713
复制相似问题