確認我使用BootstrapDialog庫來顯示模態對話框警報我使用在側BootstrapDialog.confirm方法的另一功能與像按鈕文本,消息文本等某些參數重新使用確認消息。 ...因爲我寫測試目的的波紋管代碼,但功能不返回任何東西總是返回undefined。BootstrapDialog內的另一個功能不工作
<head>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap3-dialog/1.34.7/css/bootstrap-dialog.min.css" rel="stylesheet"/>
<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap3-dialog/1.34.7/js/bootstrap-dialog.min.js"></script>
<script>
function callconfirm()
{
// var isConfirmed
BootstrapDialog.confirm({
title: 'WARNING',
message: 'Warning! Drop your banana?',
type: BootstrapDialog.TYPE_WARNING, // <-- Default value is BootstrapDialog.TYPE_PRIMARY
closable: false, // <-- Default value is false
draggable: false, // <-- Default value is false
btnCancelLabel: 'Do not drop it!', // <-- Default value is 'Cancel',
btnOKLabel: 'Drop it!', // <-- Default value is 'OK',
btnOKClass: 'btn-warning', // <-- If you didn't specify it, dialog type will be used,
callback: function(result) {
// result will be true if button was click, while it will be false if users close the dialog directly.
if(result) {
return true;
}else {
return false;
}
}
});
}
function checkConfirm()
{
var v=callconfirm();
console.log(v);
}
</script>
</head>
<body>
<button type="button" value="click" onclick="checkConfirm()" style="height: 50px;width: 50px" />
</body>
'callconfirm'不返回任何東西,所以它返回'undefined'。你想要返回'BootstrapDialog.confirm'的值嗎? – Agalo
是的,我想得到isConfirmed真或假繼續下一步 – matrixwebtech
我發佈了一個答案,檢查它是否適合你。 – Agalo