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