I am using Alertify Jquery plugin for my dialogs. The problem is that a confirm after a confirm does not seem to work:
<img onclick="go()" src="test.jpg">
<script type="text/javascript">
// confirm dialog
function go(){
alertify.confirm("Reset password?", function (e) {
if (e) {
// user clicked "ok"
secondconfirm();
} else {
// user clicked "cancel"
}
});
}
function secondconfirm(){
alertify.confirm("Password is changed<br>Mail it to the user?", function (e) {
if (e) {
//Done
alertify.success("Password reset and mailed to user.");
} else {
// user clicked "cancel"
alertify.success("Password reset.");
}
});
}
</script>
I want to use it this way because based on clicking yes or no a second question has to be asked. If I use it like this, the second confirm dialog appears very shortly and then pops out of screen. Even more annoying, the DIV that covers the rest of the screen stays in place so I can't even use the site naymore without refreshing the whole page. I guess it has something to do with the first dialog being faded out, also hiding the second one.
How to solve this?
Try to delay the execution of the secondconfirm
method's body by using the setTimeout
method:
function secondconfirm() {
setTimeout(function () {
alertify.confirm("Password is changed<br>Mail it to the user?", function (e) {
if (e) {
//Done
alertify.success("Password reset and mailed to user.");
} else {
// user clicked "cancel"
alertify.success("Password reset.");
}
});
}, 1000); // I went as low as 300 ms, but higher value is safer :)
return true;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With