I'm trying to delay the default action of clicking on a link, until the user clicks "yes" or "no" to confirm. The problem is that the while loop is freezing the browser (and not even displaying the dialog, even though "open" is called first):
$(".remove").click(function() {
$("#dialog").dialog("open");
while (1) {
// Count sheep
}
});
Obviously, the "1" is only there for testing purposes. Eventually I want it to check a variable that is set by the dialog. For now though, I want to know how I can use a loop like this to delay the default click action.
Thanks,
Michael
You can't. You have to exit the function for the dialog to show up. The browser will not do any updates at all as long as the function is running.
You have to use events to handle the user input.
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