1

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?

Akasha
  • 2,162
  • 1
  • 29
  • 47
  • you tried adding your own `window.JIRA.bind` and on the success `return true;` or to overwrite the Jira handler, not return anything to the caller.. – Pogrindis May 26 '15 at 10:57
  • 1
    If those specific JIRA event handlers are bound directly to the elements (as opposed to being attached as live-style handlers), then this seems like a duplicate of http://stackoverflow.com/questions/4742610/attaching-jquery-event-handlers-so-that-they-are-triggered-first – Scott Dudley May 26 '15 at 14:36

0 Answers0