I am trying to use callbacks in order to effectively "overwrite" the standard alert and confirm actions in JavaScript.

The code I am using is a bit long winded so I jotted it into a working [jsfiddle](https://jsfiddle.net/p83uLeop/)

I am trying to get it so that a callback is used to determine true or false, but it is coming back as undefined as the callback function is fired before a click is

My questions, is how can I change this to effectively overcome the functions value being returned before the click is called via jQuery?

Example usage:

```
<button onclick="confirm('This is a test')">Show dialog (confirm)</button>

```

Example jQuery events:

```
if (confirm("This is a test")) {
    alert("Confirmed")
}
else {
    alert("Did not confirm")
}

```

**Edit**  

Using a loop within the callback messed it us a lot...