Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #1016107

    Hi,

    I tried many alternatives to issue an alert when a POPUP is closed, BUT none resulted.
    Follow the code:

    <script type="text/javascript">
    jQuery(window).load(function(){
    jQuery('.open-popup-link').magnificPopup({
      type:'inline',
        callbacks: {
          close: function() {
              alert("Popup was closed");
    },
    },
    midClick: true 
    });
    });
    </script>
    

    I followed the documentation of the magnific popup; http://dimsemenov.com/plugins/magnific-popup/documentation.html

    Any suggestion?

    Thanks

    #1016146

    Hey CloudChoice,
    The close event occurs before the alert prompt can be created, but you can simulate the event with this:

    (function($){
      $(document).ready(function(){
            $("#test-popup").click(
                function () {
                    ShowAlert();
                });
         });
        })(jQuery);
    function ShowAlert() {
       alert("Alert Message Closed");        
    }
    

    notice it targets the ID for the popup box, my popup was like this:

    <div id="test-popup" class="white-popup mfp-hide">
    this is the content of the popup box
    </div>

    Best regards,
    Mike

    #1016169

    Ho Mike,

    The problem is that this form triggers the alert just in case you use a (X) button to close the popup.

    If you press ESC or click on the overlay it will not fire.

    Best regards,

    • This reply was modified 6 years, 1 month ago by CloudChoice.
    #1016177

    Hi,
    I see, you almost had it the first time, this one works with click & esc

    jQuery(window).load(function(){
    		jQuery('.open-popup-link').magnificPopup({
    		  type:'inline',
    		  midClick: true,
    		  callbacks: {
        beforeClose: function() {
    		ShowAlert();
    	},
    },
    		});
    		
    	});
    	function ShowAlert() {
    		   alert("Alert Message Closed");        
    		   }

    Best regards,
    Mike

    #1016721

    Hi Mike,

    The problem was 100% resolved.

    Thanks

Viewing 5 posts - 1 through 5 (of 5 total)
  • The topic ‘Alert when popup is closed’ is closed to new replies.