This commit is contained in:
Ilya Tregubov 2022-12-22 10:09:10 +07:00
commit 28f7a7c7b2
3 changed files with 8 additions and 7 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -269,13 +269,13 @@ export default class ModalForm {
*/
notifyResetFormChanges() {
const form = this.getFormNode();
FormEvents.notifyFormSubmittedByJavascript(this.getFormNode(), true);
if (!form) {
return;
}
FormChangeChecker.resetFormDirtyState(this.getFormNode());
FormEvents.notifyFormSubmittedByJavascript(form, true);
FormChangeChecker.resetFormDirtyState(form);
}
/**
@ -358,7 +358,8 @@ export default class ModalForm {
this.disableButtons();
// Convert all the form elements values to a serialised string.
const formData = this.modal.getRoot().find('form').serialize();
const form = this.modal.getRoot().find('form');
const formData = form.serialize();
// Now we can continue...
Ajax.call([{
@ -379,7 +380,7 @@ export default class ModalForm {
} else {
// Form was submitted properly. Hide the modal and execute callback.
const data = JSON.parse(response.data);
this.notifyResetFormChanges();
FormChangeChecker.markFormSubmitted(form[0]);
const event = this.trigger(this.events.FORM_SUBMITTED, data);
if (!event.defaultPrevented) {
this.modal.hide();