forked from SymfonyCasts/symfony-ux
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path2ndcontroller-listen-to-event.diff
30 lines (29 loc) · 1.2 KB
/
2ndcontroller-listen-to-event.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
diff --git a/assets/controllers/cart-list_controller.js b/assets/controllers/cart-list_controller.js
index b3f6ff5..6856d39 100644
--- a/assets/controllers/cart-list_controller.js
+++ b/assets/controllers/cart-list_controller.js
@@ -1,7 +1,7 @@
import { Controller } from 'stimulus';
export default class extends Controller {
- connect() {
- console.log('🛒');
+ removeItem(event) {
+ console.log(event.currentTarget);
}
}
diff --git a/templates/cart/cart.html.twig b/templates/cart/cart.html.twig
index c076fbd..8868958 100644
--- a/templates/cart/cart.html.twig
+++ b/templates/cart/cart.html.twig
@@ -29,7 +29,10 @@
<div class="col-3"></div>
</div>
{% for item in cart.items %}
- <div class="cart-item row p-3">
+ <div
+ class="cart-item row p-3"
+ data-action="submit-confirm:async:submitted->cart-list#removeItem"
+ >
<div class="col-2">
{{ item.product.name }}
</div>