I use BootstrapDialog library to display modal dialogs an alert an confirm messages I use BootstrapDialog.confirm method in side another function to reuse with some parameters like button text,message text etc .... for that I write bellow code for testing purpose ,but the function not return anything always return undefined .
<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>
I got a reply from from Dante creator of this plugin I share this bellow which is working fine with extra parameter .