forked from SymfonyCasts/symfony-ux
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreloadcontroller-make-ajax-call.diff
38 lines (34 loc) · 1.29 KB
/
reloadcontroller-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/reload-content_controller.js b/assets/controllers/reload-content_controller.js
index 55530b4..337c387 100644
--- a/assets/controllers/reload-content_controller.js
+++ b/assets/controllers/reload-content_controller.js
@@ -1,14 +1,13 @@
import { Controller } from 'stimulus';
export default class extends Controller {
+ static targets = ['content'];
static values = {
url: String,
}
- async removeItem(event) {
- event.currentTarget.classList.add('removing');
-
- const response = await fetch(this.cartRefreshUrlValue);
- this.element.innerHTML = await response.text();
+ async refreshContent(event) {
+ const response = await fetch(this.urlValue);
+ this.contentTarget.innerHTML = await response.text();
}
}
diff --git a/templates/product_admin/index.html.twig b/templates/product_admin/index.html.twig
index dbde87a..9a857f4 100644
--- a/templates/product_admin/index.html.twig
+++ b/templates/product_admin/index.html.twig
@@ -29,7 +29,9 @@
</div>
</div>
- {{ include('product_admin/_list.html.twig') }}
+ <div data-reload-content-target="content">
+ {{ include('product_admin/_list.html.twig') }}
+ </div>
<a href="{{ path('product_admin_new') }}">Create new</a>
</div>