form cleaned after submission endpoint notification

fix #3897
This commit is contained in:
gabryon99 2020-05-06 16:39:28 +02:00
parent 010ea26c85
commit 584f015328
2 changed files with 5 additions and 10 deletions

View file

@ -26,10 +26,6 @@
this.options.onModalInit(this.fillFormModal());
}
updateCsrf(newCsrf) {
this.csrf = newCsrf;
}
delegateSubmit() {
this.bindFormValidation();
@ -89,7 +85,7 @@
const submitButton = $(this.element).find(`[type='submit']`);
let dataToSend = this.options.beforeSumbit();
if (this.options.method == 'post') dataToSend.csrf = this.csrf;
dataToSend.csrf = this.csrf;
dataToSend = $.extend(dataToSend, this.options.submitOptions);
/* clean previous state and disable button */
@ -100,8 +96,7 @@
method(this.options.endpoint, dataToSend)
.done(function (response, textStatus) {
if (response.csrf) self.updateCsrf(response.csrf);
if (self.resetAfterSubmit) self.cleanForm();
if (self.options.resetAfterSubmit) self.cleanForm();
self.options.onSubmitSuccess(response, dataToSend);
/* unbind the old closure on submit event and bind a new one */
$(self.element).off('submit', self.submitHandler);