Rich-text Reply

Timing of Modal Only Showing Once

smcurrey528 08-05-19
Accepted Solution

Timing of Modal Only Showing Once

Hi, I am currently using the lightbox extension in Optimizely, but we want the modal to only appear once per session. I tried the code below and there is some flashing of the modal before it is hidden. Is it because of the waitForElement? Optimizely recommends that as a way to fix timing issues on their help pages.


var utils = window.optimizely.get('utils');
utils.waitForElement('.lightbox_extension').then( function(modal){
var summerModal = sessionStorage.getItem('seenOnDemandModal');
  if (!summerModal){ = "block";
    sessionStorage.setItem('seenOnDemandModal', 'true');
} else if (summerModal === 'true') { = "none";
CouchPsycho 08-06-19

Re: Timing of Modal Only Showing Once


if you want to prevent the flashing, set the element style to display:none by default. The flashing may result, as you have already mentioned, because of the interval waitForElement is checking the existence of the element.

Kind regards