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

This widget could not be displayed.

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.

This widget could not be displayed.

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

Suggest an answer

Log in or Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted Wednesday in Teamwork

What teamwork quotes inspire you?

Hey everyone! My name is Natalie and I'm an editor of the Atlassian Blog and I've got a question for you: What's your favorite quote about teamwork?  We've compiled a list here, along with...

140 views 16 7
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