From fa6deebaaf84188d23708af72d0ac68d8a0d5602 Mon Sep 17 00:00:00 2001 From: Tushar Gugnani Date: Sat, 14 Jan 2023 19:02:13 +0530 Subject: [PATCH] fix click issue --- resources/dist/js/smart-banner.js | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/resources/dist/js/smart-banner.js b/resources/dist/js/smart-banner.js index 23b9bfe..fa9ebd3 100644 --- a/resources/dist/js/smart-banner.js +++ b/resources/dist/js/smart-banner.js @@ -16,16 +16,20 @@ fetch('/smart-banner-auto-placements') }); //Remove the parent temp element (smart-ad-temp), since it messes with the CSS Design for some ads - var smartAd = document.querySelector('.smart-banner-temp'); - if(smartAd){ - let adSlug = smartAd.getAttribute('banner-slug'); - smartAd.firstElementChild.setAttribute("banner-slug", adSlug); - smartAd.firstElementChild.classList.add("smart-banner"); - document.querySelectorAll(".smart-banner-temp").forEach(EL => EL.replaceWith(...EL.childNodes)); - - //Attach click event - document.querySelector('.smart-banner').addEventListener('click', updateClick); - } + var smartAds = document.querySelectorAll('.smart-banner-temp'); + //console.log(smartAds); + smartAds.forEach(function(smartAd){ + let adSlug = smartAd.getAttribute('banner-slug'); + smartAd.firstElementChild.setAttribute("banner-slug", adSlug); + smartAd.firstElementChild.classList.add("smart-banner"); + smartAd.replaceWith(...smartAd.childNodes); + }); + + var smartAds = document.querySelectorAll('.smart-banner'); + smartAds.forEach(function(smartAd){ + smartAd.addEventListener('click', updateClick); + }); + }); //Event listener function for updating clicks