forked from SymfonyCasts/symfony-ux
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreviews-fix-disabled-buttons-on-back.diff
33 lines (30 loc) · 1.16 KB
/
reviews-fix-disabled-buttons-on-back.diff
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
diff --git a/assets/turbo/turbo-helper.js b/assets/turbo/turbo-helper.js
index 02e51e0..628a863 100644
--- a/assets/turbo/turbo-helper.js
+++ b/assets/turbo/turbo-helper.js
@@ -5,10 +5,13 @@ const TurboHelper = class {
document.addEventListener('turbo:before-cache', () => {
this.closeModal();
this.closeSweetalert();
+ this.reenableSubmitButtons();
});
document.addEventListener('turbo:submit-start', (event) => {
- event.detail.formSubmission.submitter.toggleAttribute('disabled', true);
+ const submitter = event.detail.formSubmission.submitter;
+ submitter.toggleAttribute('disabled', true);
+ submitter.classList.add('turbo-submit-disabled');
})
this.initializeTransitions();
@@ -85,6 +88,13 @@ const TurboHelper = class {
}
});
}
+
+ reenableSubmitButtons() {
+ document.querySelectorAll('.turbo-submit-disabled').forEach((button) => {
+ button.toggleAttribute('disabled', false);
+ button.classList.remove('turbo-submit-disabled');
+ });
+ }
}
export default new TurboHelper();