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.
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