确认我使用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