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

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
Accepted answer

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

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.

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

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Friday in Jira Service Desk

Looking for anyone who has switched from Zendesk to Jira Service Desk

Hi Community! The Jira Service Desk marketing team is looking for customers who have successfully switched from Zendesk to Jira Service Desk!   We’d love to hear your thoughts on the pros and ...

51 views 2 2
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you