Not possible to stop propagation of JavaScipt event (Submit) in JIRA 5.x.

Jakub Papcun July 24, 2012

Hi all,


when creating (editting) an issue in JIRA I need to check some fields if they are not empty or not selected and if so, stop the submission of the creating/editting the issue so that the user can fill in the fields. The problem is that if I try to use this style of the code

AJS.$('form').submit(function(){
    if(!someValidation){
        return false;
    }
}

The handling of the event goes well the problem is that even if the handling is executed and the propagation of the event should be stopped by the jQuery the submission still executes even though it enters the "if" and returns false. Is this some feature of JIRA 5.x where in popup window (create/edit screen) is impossible to do it this way? If so is there some workaround to stop submission or is this not allowed in JIRA 5.x at all?


Thanks for any info in advance.

2 answers

1 accepted

1 vote
Answer accepted
Jakub Papcun July 29, 2012

Hi all,

found the answer to this. It is necessary to use "before-submit" event for this. I.e.:

AJS.$('form').bind("before-submit", function(event){
    if(!someVerification){
        event.preventDefault(); // this will stop the event from further propagation and the submission will not be executed
        event.stopPropagation(); //not always necessary
    }
});

fsdfdsafsd

Igor Loskutov
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 29, 2012

I faced with that problem before but avoided it by disabling submit button when verification not right. This solution by you is fine too and I think that would use it in future. Thanks for you question and answer.

0 votes
Gopinath Velayudhan July 10, 2013

Can you please provide your code on how to disable to Submit / create button?

Suggest an answer

Log in or Sign up to answer