Intercept click event on a button, ask for confirmation, then proceed
- by Blankman
Based on a variable SomeCondition, I need to intercept a click event on a button, and ask for confirmation, if they say ok, proceed, otherwise ignore click.
So something like:
if(SomeCondition) {
// disable click on button
var isOk = window.confirm("Are you sure?");
if(isOk) {
$("#button1").click();
}
}
Note: button1 has already been wired up with a click event via javascript from an external .js file that I can't change.
I don't know what the click event was bound too, so I have to disable the click if SomeCondition is true, then ask for confirmation, then continue with the click.