我想禁用甜蜜提醒中显示的按钮,这样我的用户就不能一次又一次地单击该按钮。我附上了警报的屏幕截图 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';
});
}
});
最佳答案
这里是你可以尝试的,如果你不想显示任何按钮,你也可以添加超时,这样它就会在一段时间后关闭。
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';
});
}
});
关于javascript - 我可以禁用 sweet alert js 按钮吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37590104/