Jeremy
Jeremy

Reputation: 973

Adding onclose method in magnificPopup (that autoloads on pageload)

We have here a good example of adding onclose functions for magnificPopup.

However, this works when we call magnificPopup with an onclick event. I was wondering how to add onclose functions when magnificPopup autoloads on pageload.

Here is the code:

<?
if (is_array($flashMessage) && count($flashMessage) > 0) {
?>
<script>
$(document).ready(function() {
  $.magnificPopup.open({
      items: {
          src: '#confirmation',
          type:'inline'
      }
    });
});
</script>
<? } ?>

On this, I need to add onclose event with window.location. Thanks for any help.

Upvotes: 0

Views: 250

Answers (1)

Bogdan Kuštan
Bogdan Kuštan

Reputation: 5577

The same?

$.magnificPopup.open({
items : {
    src: '#test-popup',
},
type: 'inline',
    callbacks: {
        open: function () {
            $.magnificPopup.instance.close = function () {
                var confirmed = confirm("Are you sure?"+window.location.href);
                if (!confirmed) {
                    return;
                }
                $.magnificPopup.proto.close.call(this);
            };
        }
    }
});

I guess You had problems with type:'inline' in items object. Working fiddle

Upvotes: 1

Related Questions