Do not show pop up if another has shown.

Hi, we have two pop ups, one that is triggered after a few seconds and one that is trigged by a click. We need to prevent the first popup from showing if the click event has occurred.

  • Adam Czajczyk
    • Support Gorilla

    Hello colind,

    That sounds like it might be possible though it would probably require some custom JS. My colleague Predrag has already forwarded your question to the developers and we’re waiting for their response. We (or one of the developers directly) will update this ticket for you once we get some more information on possible solution here.

    Best regards,

    Adam

  • Panos
    • SLS

    Hi colind ,

    Could you please try adding the following in your theme’s functions.php or in a mu-plugin:

    add_action( 'wp_footer', function(){

    ?>

    <script type="text/javascript">

    (function($) {
    var MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver;

    $.fn.attrchange = function(callback) {
    if (MutationObserver) {
    var options = {
    subtree: false,
    attributes: true
    };

    var observer = new MutationObserver(function(mutations) {
    mutations.forEach(function(e) {
    callback.call(e.target, e.attributeName);
    });
    });

    return this.each(function() {
    observer.observe(this, options);
    });

    }
    }

    $(document).ready(function(){

    var popup_shown = false;
    $('body *').attrchange(function(attrName) {

    if(attrName=='class'){

    if( popup_shown ){
    if( $(this).attr('class').indexOf( 'inc_optin' ) ){
    $(this).hide().remove();
    }
    } else if( $(this).attr('class').indexOf( 'inc_optin' ) !== -1 ){
    popup_shown = true;
    }

    }else if(attrName=='id'){

    }else{

    }

    });
    });

    })(jQuery);

    </script>

    <?php

    }, 10 );

    and let us know if it helps?

    Thanks!

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.