Update
I tested the code I posted previously and I found that it doesn't work quite right. This is tested and works exactly as you wanted, plus its a drop in solution:
var event_store;
function handle_click(event) {
event.stopPropagation();
event_store = event;
//Open the modal here
//If it's possible, pass the event pointer to the modal's confirm callback
//instead of using event_store and pass that pointer to fire_event() when
//it's confirmed
}
function confirm_handle() {
resume_event("click");
}
function resume_event(type) {
if (event_store.target.parentNode) {
var event;
if (document.createEvent) {
event = document.createEvent("HTMLEvents");
event.initEvent(type, true, true);
} else {
event = document.createEventObject();
event.eventType = type;
}
event.eventName = type;
if (document.createEvent) { //Not IE
event_store.target.parentNode.dispatchEvent(event);
} else { //IE
event_store.target.parentNode.fireEvent("on" + event.eventType, event);
}
}
}
Previous
You could use something like this to "pause" the event bubbling. It cancels the event propagation and shows the modal when the click handler is called and sets the show_modal variable to false. Upon confirming fire_event() is called and it triggers the original event, this time not showing the modal, then resets show_modal back to true. You should also rest show_modal back to true in the event that the user does not confirm the modal.
var show_modal = true;
var event_store;
function handle_click(event) {
event.stopPropagation();
event_store = event;
show_modal = !show_modal;
if (show_modal) {
//Open the modal here
//If it's possible, pass the event pointer to the modal's confirm callback
//instead of using event_store and pass that pointer to fire_event() when
//it's confirmed
}
}
function fire_event() {
if (document.createEvent) { //Not IE
element.dispatchEvent(event_store);
} else { //IE
element.fireEvent("on" + event_store.eventType, event_store);
}
}