我想禁用甜蜜警报中显示的按钮,这样我的用户就无法一次又一次地点击该按钮。我附上了提醒here
的屏幕截图我想禁用确认按钮(我不希望关闭提醒):
swal({
title: "Are you sure?",
text: "You want to add this discount?",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "Continue",
cancelButtonText: "Cancel",
closeOnConfirm: false,
closeOnCancel: false
}, function (isConfirm) {
if (isConfirm) {
document.getElementById('message_error_new_discount').innerHTML = '';
$.post('./CURL/addNewDiscount.php', JSON.stringify({
"code": discount_code_newDiscount,
"percentage": percentage_newDiscount,
"startDate": sdate_newDiscount,
"endDate": edate_newDiscount
}), function (data) {
var text = "your discount code is " + data.code;
swal({ title: "Discount Added!", text: text, type: "success" }, function () {
window.location = './discountlist.php';
});
});
} else {
swal({ title: "Cancelled", text: "", type: "error" }, function () {
window.location = './discountlist.php';
});
}
});
答案 0 :(得分:4)
以下是您可以尝试的内容,如果您不想显示任何按钮,也可以添加超时,以便在一段时间后关闭。
swal({
title: "Are you sure?",
text: "You want to add this discount?",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "Continue",
cancelButtonText: "Cancel",
closeOnConfirm: false,
closeOnCancel: false
}, function(isConfirm){
if (isConfirm) {
document.getElementById('message_error_new_discount').innerHTML = '';
$.post('./CURL/addNewDiscount.php',JSON.stringify({
"code": discount_code_newDiscount,
"percentage": percentage_newDiscount,
"startDate": sdate_newDiscount,
"endDate": edate_newDiscount
}),function(data){
var text = "your discount code is "+data.code;
swal({title:"Discount Added!",
text:text,
type:"success",
showCancelButton: false,//There won't be any cancle button
showConfirmButton : false //There won't be any confirm button
},function(){
window.location='./discountlist.php';
});
});
}else{
swal({title:"Cancelled",text:"", type:"error"},function(){
window.location='./discountlist.php';
});
}
});
答案 1 :(得分:0)
这对我有用:$(".confirm").attr('disabled', 'disabled')
;
function DeleteConfirm(c){
swal({
title: "Want to delete this item?",
text: "You will not be able to undo this action!",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "Yes, delete it!",
closeOnConfirm: false
}, function(){
$(".confirm").attr('disabled', 'disabled');
});
}