1
返回值
我使用sweetalert插件,顯示通知... 現在我需要從是獲得價值/未確認從sweetAlert
function confirm(message) {
swal({
title: "Are you sure?",
text: message,
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "Yes",
cancelButtonText: "No",
closeOnConfirm: false,
closeOnCancel: false
},
function(isConfirm){
if (isConfirm) {
return true;
} else {
return false;
}
});
}
然後
if (confirm("my message")) myFunction();
我可以打電話myFunction() from isconfirm swal,但我有很多「myFunction()」,我不想重寫每個這些swal ...