I'm writing a usermonkey/tampermonkey script for JIRA, and would like to attach a confirm window given a certain condition on a dialog. The dialog is submitted using jQuery's $form.submit handler using the following code:
this.$form.submit(function(e) {
var event = new jQuery.Event("before-submit");
instance.$form.trigger(event, [e, instance]);
if (!event.isDefaultPrevented()) {
instance.options.submitHandler.call(instance, e, function() {... })
} else {
e.preventDefault()
}
The this.$form element is generated dynamically, I can already access this from my userscript as
window.JIRA.bind(window.JIRA.Events.NEW_CONTENT_ADDED, function(g, f) {
var event = new jQuery.Event("before-submit")
$("form.aui", "#create-issue-dialog").on(event, function(ev, instance) {
console.log("this is not called");
if(!confirm("Go?")) {
ev.preventDefault();
ev.stopImmediatePropagation();
return false;
}
});
});
How can I arrive to a state that stops the original JIRA submit handler?