Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to reset AUI form validation for a Dialog2

Azbel Eden Garcia Escalante
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
September 10, 2024

Hello, everyone.

I'm developing a Jira plugin for Jira DC 9.12.11 and using AUI 7.9.9 form validation for a AUI Dialog2. I'm using jQuery and JS to show and hide the dialog for different table rows within the same HTML so every time a dialog is shown the content is repopulated using Ajax for each row data by using:

 

AJS.dialog2("#my-view-dialog").show();
AJS.dialog2("#my-view-dialog").hide();
AJS.dialog2("#my-view-dialog").on("show", function() { //Logic here });

The form within the dialog is validating the inputs correctly by using the property data-aui-validation-field. 

The issue I'm facing is that when having validation errors after closing the dialog using Cancel button and opening same dialog for whatever row in the table, the validation errors on fields are always shown, and by only triggering the submit and event aui-valid-submit is triggered the errors can be cleared.

AJS.$('#valid-submit-form').on('aui-valid-submit', function(event) {
    console.log('Data saved');
    event.preventDefault();
});

Is there any way of resetting the validation to the original state so the errors can be cleared every time the dialog is shown? I've already tried the following without success, so there's no way to clear the validation state and errors are always shown:

  • Trigger aui-valid-submit event using jQuery when closing the dialog.
  • Setting correct values before closing the dialog to clear the errors.
  • Removing the dialog from DOM using data-aui-remove-on-hide on the Dialog2 HTML attribute and adding it again.
  • Saving the state of the dialog section/form/fields by using jQuery clone() and re-adding them again.

Thank you in advance if you can provide me with any help on this AUI issue.

1 answer

0 votes
Azbel Eden Garcia Escalante
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
September 11, 2024

I was able to fix it by removing the attributes data-aui-notification-error, data-aui-validation-state and data-aui-validation-dateformat, and by setting them again accordingly.

Suggest an answer

Log in or Sign up to answer