forked from SymfonyCasts/symfony-ux
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathasyncform-close-on-success.diff
28 lines (26 loc) · 1 KB
/
asyncform-close-on-success.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
diff --git a/assets/controllers/modal-form_controller.js b/assets/controllers/modal-form_controller.js
index 85873ba..a59fd79 100644
--- a/assets/controllers/modal-form_controller.js
+++ b/assets/controllers/modal-form_controller.js
@@ -7,11 +7,12 @@ export default class extends Controller {
static values = {
formUrl: String,
}
+ modal = null;
async openModal(event) {
this.modalBodyTarget.innerHTML = 'Loading...';
- const modal = new Modal(this.modalTarget);
- modal.show();
+ this.modal = new Modal(this.modalTarget);
+ this.modal.show();
this.modalBodyTarget.innerHTML = await $.ajax(this.formUrlValue);
}
@@ -26,7 +27,7 @@ export default class extends Controller {
method: $form.prop('method'),
data: $form.serialize(),
});
- console.log('success!');
+ this.modal.hide();
} catch (e) {
this.modalBodyTarget.innerHTML = e.responseText;
}