Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/416.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 我可以禁用sweet alert js按钮吗?_Javascript_Jquery_Sweetalert - Fatal编程技术网

Javascript 我可以禁用sweet alert js按钮吗?

Javascript 我可以禁用sweet alert js按钮吗?,javascript,jquery,sweetalert,Javascript,Jquery,Sweetalert,我想禁用sweet alerts中显示的按钮,以便我的用户不能反复单击该按钮。我已附上警报的屏幕截图 我想禁用确认按钮(我不想关闭警报): 这里是你可以尝试的,如果你不想显示任何按钮,你也可以添加超时,这样它将在一段时间后关闭 swal({ title: "Are you sure?", text: "You want to add this discount?", type: "warning", showCancelButton: tr

我想禁用sweet alerts中显示的按钮,以便我的用户不能反复单击该按钮。我已附上警报的屏幕截图

我想禁用确认按钮(我不想关闭警报):


这里是你可以尝试的,如果你不想显示任何按钮,你也可以添加超时,这样它将在一段时间后关闭

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';
        });
    }
});
这对我很有用:
$(.confirm”).attr('disabled','disabled')

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';
        });
    }
});
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'); 

        });
}