What I'm trying to do is: when the user clicks the cancel button or moves from the page by a link or menu option, I check if there are unsaved changes. If so, I ask the user if he / she wants to save. I cannot do this using the javascript confirmation window, because sometimes I have more than two parameters, so I cannot “hold” everything until the user makes a choice, for example confirmation. Therefore, I, however, in order to “save” the event, cancel its current execution, wait for the user to use his mind, and then take the necessary actions in accordance with their response, and then raise the original event. So, as an example code of what I thought: I have this piece of code:
var executingEvent; function someFunction() { ... if(existUnsavedChanges) { showConfirmMessage(); executingEvent = window.event; if (executingEvent.stopPropagation) { executingEvent.stopPropagation(); } else { executingEvent.cancelBubble = true; } ... } }
Is there a way to do something similar later?
raise (executingEvent);
It sounds a little complicated, I would also welcome other options :)
source share