Sorry for the weird title, I couldn't think of a better way to word it.
The situation is: I have a link that is generated by a complex system (can't be changed), which fires a JS function when clicked.
Instead, when the link is clicked I want a modal box to appear asking the user if they are sure. If they choose yes then the original JS function will run. If not then the modal closes and nothing happens.
Is it possible to unbind, capture, and rebind the original function like this?
Pseudo-code would be as follows, hopefully it's possible:
$('a.link').click(function(){
// *** Capture original JS function bound to link ***
// *** var agree = Run new function (open modal box) ***
if(agree === true){
// *** Run original function ***
}else{
// *** Close modal box ***
}
});
I'm probably thinking about this the wrong way, if there is a better one please let me know!