File tree Expand file tree Collapse file tree
view/frontend/templates/script/component/category Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -9,11 +9,17 @@ use Magento\Framework\View\Element\Template;
99?>
1010<script>
1111 document.addEventListener('alpine:init', () => {
12- const forms = document.querySelectorAll('[data-js-component="LumaAddToCompare"]');
13- if (!forms ) {
12+ const elements = [... document.querySelectorAll('[data-js-component="LumaAddToCompare"]')] ;
13+ if (!elements ) {
1414 return;
1515 }
1616
17- console.log('add to compare');
17+ elements.forEach(element => {
18+ element.addEventListener('click', (e) => {
19+ e.preventDefault();
20+
21+ LokiDataPost(element);
22+ });
23+ })
1824 });
1925</script>
Original file line number Diff line number Diff line change @@ -8,21 +8,23 @@ use Magento\Framework\View\Element\Template;
88?>
99<script>
1010 document.addEventListener('alpine:init', () => {
11- const element = document.querySelector ('[data-js-component="LumaAddToWishlist"]');
12- if (!element ) {
11+ const elements = [... document.querySelectorAll ('[data-js-component="LumaAddToWishlist"]')] ;
12+ if (!elements.length > 0 ) {
1313 return;
1414 }
1515
16- element.addEventListener('click', (e) => {
17- e.preventDefault();
16+ elements.forEach((element) => {
17+ element.addEventListener('click', (e) => {
18+ e.preventDefault();
1819
19- const customerSection = Alpine.store('LokiLocalStorage').get('customer');
20- if (!customerSection.fullname) {
21- Alpine.store('LokiMessageStore').addNoticeMessage('<?= __ ('You need to login to use the wishlist ' ) ?> ');
22- return;
23- }
20+ const customerSection = Alpine.store('LokiLocalStorage').get('customer');
21+ if (!customerSection.fullname) {
22+ Alpine.store('LokiMessageStore').addNoticeMessage('<?= __ ('You need to login to use the wishlist ' ) ?> ');
23+ return;
24+ }
2425
25- LokiDataPost(element);
26+ LokiDataPost(element);
27+ });
2628 })
2729 });
2830</script>
You can’t perform that action at this time.
0 commit comments