forked from SymfonyCasts/symfony-ux
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodalframe-remove-modal-form-target.diff
54 lines (52 loc) · 1.76 KB
/
modalframe-remove-modal-form-target.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
diff --git a/assets/controllers/modal-form_controller.js b/assets/controllers/modal-form_controller.js
index 6206616..0d0afbc 100644
--- a/assets/controllers/modal-form_controller.js
+++ b/assets/controllers/modal-form_controller.js
@@ -4,7 +4,7 @@ import $ from 'jquery';
import { useDispatch } from 'stimulus-use';
export default class extends Controller {
- static targets = ['modal', 'modalBody'];
+ static targets = ['modal'];
static values = {
formUrl: String,
}
@@ -15,27 +15,7 @@ export default class extends Controller {
}
async openModal(event) {
- this.modalBodyTarget.innerHTML = 'Loading...';
this.modal = new Modal(this.modalTarget);
this.modal.show();
-
- this.modalBodyTarget.innerHTML = await $.ajax(this.formUrlValue);
- }
-
- async submitForm(event) {
- event.preventDefault();
- const $form = $(this.modalBodyTarget).find('form');
-
- try {
- await $.ajax({
- url: this.formUrlValue,
- method: $form.prop('method'),
- data: $form.serialize(),
- });
- this.modal.hide();
- this.dispatch('success');
- } catch (e) {
- this.modalBodyTarget.innerHTML = e.responseText;
- }
}
}
diff --git a/templates/_modal.html.twig b/templates/_modal.html.twig
index f893b54..df87b80 100644
--- a/templates/_modal.html.twig
+++ b/templates/_modal.html.twig
@@ -14,8 +14,6 @@
</div>
<turbo-frame
class="modal-body"
- data-modal-form-target="modalBody"
- data-action="submit->modal-form#submitForm"
src="{{ modalSrc }}"
>
{{ modalContent|default('Loading...') }}