Jquery will warn confirmation after confirmation does not work

I use Alertify jQuery for my dialogs. The problem is that confirmation after confirmation does not 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 like that, because on the basis of clicking yes or no, I need to ask a second question. If I use it like this, the second confirmation dialog will appear very briefly and then pop out of the screen. Even more annoying, the DIV that covers the rest of the screen stays in place, so I can't even use the nymore site without refreshing the entire page. I suppose this has something to do with the fact that the first dialogue disappears and also hides the second.

How to solve this?

+4
source share
2 answers

Try to delay the execution of the body of the secondconfirm method using the setTimeout :

 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; } 
+2
source

It really requires an alert. Can we just try with confirmation.

 if(confirm("Reset password?")) { // user clicked "ok" secondconfirm(); } else { // user clicked "cancel" } function secondconfirm(){ if(confirm("Password is changed<br>Mail it to the user?") { //Done alert("Password reset and mailed to user."); } else { // user clicked "cancel" alert("Password reset."); } } 
0
source

Source: https://habr.com/ru/post/1483931/


All Articles