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
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
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,
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
Hi Mike,
The problem was 100% resolved.
Thanks