What is the problem with bootbox.confirm()? This is my code:
var record = bootbox.confirm("Are you sure you want to delete", function (res) {
if (res == true) {
return true;
} else {
return false;
}
}
});
It doesn't wait for confirmation and return true by default. if is use return false at the end to stop it from disappearing
var record = bootbox.confirm("Are you sure you want to delete",
function (res) {
if(res == true)
{
return true;
}
else
{
return false;
}
}
});
return false;
then it doesn't show any action against of clicking of "OK" or "cancel"
if i use any simple alert in true section to check behaviour it enters in true section and show simple alert and show required value of clicked button but if use return true in same section but it doesnt work
var record = bootbox.confirm("Are you sure you want to delete", function (res) {
if (res == true)
alert('true');
else
alert('false')
}
});
return false;
I got the solution , bootstrap.confirm() is asynchronous in behaviour so we can't stop its flow but we can change our logic to use it like
first of all we have to stop its default behaviour and then use it as our requirment
whatever we want to do place it under the true section of the code
e.preventDefault();// used to stop its default behaviour
bootbox.confirm(Are you sure you want to delete ? , function (confirmed) {
if (confirmed == true) {
// place here what we want to do
__doPostBack('btnDelete', 'OnClick');
}
else
{
}
});