显示甜蜜警报对话框时出错
Error in displaying sweet alert dialog
我正在尝试使用 Sweet Alert 库发出警报。
我试图集成代码来发出删除项目的确认警报,但是当我单击删除项目的按钮时,这些代码不起作用。不显示对话框。
在 集成 Sweet Alert 之前的代码 :
$(".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 Alert 之后:
$(".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;
});
我认为您的代码中存在语法错误。试试这个,看看它是否有效[我还没有测试我这边的代码]。如果它不起作用,请告诉我
$(".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;
});
我正在尝试使用 Sweet Alert 库发出警报。 我试图集成代码来发出删除项目的确认警报,但是当我单击删除项目的按钮时,这些代码不起作用。不显示对话框。
在 集成 Sweet Alert 之前的代码 :
$(".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 Alert 之后:
$(".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;
});
我认为您的代码中存在语法错误。试试这个,看看它是否有效[我还没有测试我这边的代码]。如果它不起作用,请告诉我
$(".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;
});