forked from SymfonyCasts/symfony-ux
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjquery-make-ajax-call.diff
38 lines (36 loc) · 1.29 KB
/
jquery-make-ajax-call.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
diff --git a/assets/controllers/modal-form_controller.js b/assets/controllers/modal-form_controller.js
index 10fa04d..bdbe49e 100644
--- a/assets/controllers/modal-form_controller.js
+++ b/assets/controllers/modal-form_controller.js
@@ -1,15 +1,17 @@
import { Controller } from 'stimulus';
import { Modal } from 'bootstrap';
+import $ from 'jquery';
export default class extends Controller {
- static targets = ['modal'];
+ static targets = ['modal', 'modalBody'];
static values = {
formUrl: String,
}
- openModal(event) {
- console.log(this.formUrlValue);
+ async openModal(event) {
const modal = new Modal(this.modalTarget);
modal.show();
+
+ this.modalBodyTarget.innerHTML = await $.ajax(this.formUrlValue);
}
}
diff --git a/templates/_modal.html.twig b/templates/_modal.html.twig
index 6161b48..550a93a 100644
--- a/templates/_modal.html.twig
+++ b/templates/_modal.html.twig
@@ -12,7 +12,7 @@
data-bs-dismiss="modal"
aria-label="Close"></button>
</div>
- <div class="modal-body">
+ <div class="modal-body" data-modal-form-target="modalBody">
{{ modalContent|default('Loading...') }}
</div>
<div class="modal-footer">