Skip to content

Commit

Permalink
Dispatch event when product has been added/removed from wishlist
Browse files Browse the repository at this point in the history
  • Loading branch information
loevgaard committed Nov 26, 2024
1 parent d9230d9 commit 8697777
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/Resources/public/js/wishlist-action-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,13 @@ class WishlistActionHandler {

element.dataset.url = json.toggleUrl;
element.classList.toggle('ssw-added', json.event === 'added');

element.dispatchEvent(new CustomEvent(`ssw:product-${json.event}`, {
bubbles: true,
detail: {
wishlistItemsCount: json.wishlistItemsCount,
},
}));
},
}
},
Expand All @@ -64,4 +71,4 @@ class WishlistActionHandler {
}
}

new WishlistActionHandler(window.ssWishlist || {});
new WishlistActionHandler(window.sswWishlist || {});

0 comments on commit 8697777

Please sign in to comment.