iframemanager icon indicating copy to clipboard operation
iframemanager copied to clipboard

Ist there a way to re-run?

Open mountbatt opened this issue 1 year ago • 2 comments

Hi,

i am loading some video portfolios via ajax on an wordpress theme. Is there a way to re-run the script to detect the that are new to the dom?

Thanks for your help!

Cheers Tobias

mountbatt avatar Nov 16 '23 11:11 mountbatt

+1 on this. Facing the exact same issue. Running a combination of

cc.reset();
cc.run(cookieConsentConfig);
manager.run(managerConfig);

on each dynamic page load works, but only if the user clicks the "Load once" button. Clicking "Don't ask again" breaks the script. This probably also has to do with the CookieConsent reset() function not being able to detect already executed scripts.

eistruhe avatar Nov 21 '23 10:11 eistruhe

I create the hotfix this issue. When a page change occurs in react / next.js, it does not detect DOM changed. My solution reset and re-run iframemanager at each page change. PR #55

import { useRouter } from 'next/router'
...

useEffect(() => {
  // const cc = initCookieConsent()
  const im = iframemanager()
 
  setTimeout(() => {
      im.run(...)
  }, 1000) // Since it is not SSR, it is necessary to allow time for the client to render it

  return () => {
    im.reset() // stop observers, reset scoped variables
  }
}, [router.asPath])
...

icetee avatar May 05 '24 11:05 icetee