From d7260dfa2457ca883dba3ec8a0f80bfe16245d1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Igor=20Ste=CC=A8pien=CC=81?= Date: Tue, 10 Oct 2023 00:06:22 +0200 Subject: [PATCH] Quickview vanilla.js --- _dev/js/theme/components/quickview.js | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/_dev/js/theme/components/quickview.js b/_dev/js/theme/components/quickview.js index f9d5baa6..bc27665f 100644 --- a/_dev/js/theme/components/quickview.js +++ b/_dev/js/theme/components/quickview.js @@ -1,4 +1,3 @@ -import $ from 'jquery'; import prestashop from 'prestashop'; import DOMReady from '../utils/DOMReady'; import parseToHtml from '../utils/parseToHtml'; @@ -6,21 +5,18 @@ import parseToHtml from '../utils/parseToHtml'; /** * Handle open quick view */ -const handleQuickViewOpen = ({ - resp, -}) => { - const body = document.querySelector('body'); - body.append(parseToHtml(resp.quickview_html)); +const handleQuickViewOpen = ({ resp }) => { + const body = document.body; - // TO DO REMOVE JQUERY - const productModal = $( - `#quickview-modal-${resp.product.id}-${resp.product.id_product_attribute}`, - ); - productModal.modal('show'); + const quickviewHtml = parseToHtml(resp.quickview_html); + body.appendChild(quickviewHtml); + + const productModal = document.getElementById(`quickview-modal-${resp.product.id}-${resp.product.id_product_attribute}`); + productModal.classList.add('show'); body.classList.add('js-quickview-open'); - productModal.on('hidden.bs.modal', () => { + productModal.addEventListener('hidden.bs.modal', () => { productModal.remove(); body.classList.remove('js-quickview-open'); });