Here's the JSFiddle for what u needed JSFiddle. Here in the code you can use your own div id like you have used in your case, in the src field. Your code was missing the extra function call which would be made when we close the popup.

Here in the code, a function call is made before closing the popup as you needed. Hope this helps.

Answer from Jennis Vaishnav on Stack Overflow
🌐
Dimsemenov
dimsemenov.com › plugins › magnific-popup › documentation.html
Magnific Popup Documentation
You can define callbacks in callbacks option. Besides that, all Magnific Popup events are also dispatched using triggerHandler on target element (or to document if the element doesn’t exist).
🌐
Experts Exchange
experts-exchange.com › questions › 28279463 › Magnific-Popup.html
Solved: Magnific Popup | Experts Exchange
October 28, 2013 - <script type="text/javascript"> var hasEndBeenReached = false; $(document).ready(function() { $('.mro').magnificPopup({ delegate: 'a', type: 'image', closeBtnInside: true, tLoading: 'Loading image #%curr%...', mainClass: 'mfp-fade', gallery: { enabled: true, navigateByImgClick: true, preload: [1,6], Counter: '<span class="mfp-counter">%curr% of %total%</span>' }, image: { tError: '<a href="%url%">The image #%curr%</a> could not be loaded.', titleSrc: function(item) { return item.el.attr('title') + '<small>Maintenance, Repair and Overhaul</small>'; } }, callbacks: { change: function() { if (this.index==(this.items.length - 1) && hasEndBeenReached==false) { hasEndBeenReached = true; } if (hasEndBeenReached == true && this.index<(this.items.length - 1)) { hasEndBeenReached = false; this.close(); } } } }); }); </script>
🌐
GitHub
github.com › dimsemenov › Magnific-Popup › issues › 122
Magnific Popup Callback when closing · Issue #122 · dimsemenov/Magnific-Popup
June 19, 2013 - Magnific Popup Callback when ... This is my demo http://jsfiddle.net/K9Geq/ If user click cancel the Popup should remain as it is, Or if user click Ok, We need to close the Popup....
Author   mifas
🌐
GitHub
github.com › dimsemenov › Magnific-Popup › issues › 632
Suggestion: add an afterOpen callback · Issue #632 · dimsemenov/Magnific-Popup
February 17, 2015 - dimsemenov / Magnific-Popup Public · Notifications · You must be signed in to change notification settings · Fork 3.4k · Star 11.4k · New issueCopy link · New issueCopy link · Closed · Closed · Suggestion: add an afterOpen callback#632 · Copy link · styledev ·
Author   styledev
🌐
GitHub
github.com › dimsemenov › Magnific-Popup › issues › 873
Callback On Init Complete · Issue #873 · dimsemenov/Magnific-Popup
June 23, 2016 - Hello, I am using a slider along with Magnific-Popup. I would like to instantiate the slider AFTER Magnific-Popup completes, but I can not seem to find any type of any event I can watch for or callback that I can use that will be fired o...
Author   jeffconklin
Find elsewhere
🌐
CodePen
codepen.io › dimsemenov › pen › DrmzyY
Custom action before close / Confirm closing
$('#open-popup').magnificPopup({ type:'inline', callbacks: { open: function() { // this part overrides "close" method in MagnificPopup object $.magnificPopup.instance.close = function () { if (!confirm("Are you sure?")) { return; } // "proto" variable holds MagnificPopup class prototype // The above change that we did to instance is not applied to the prototype, // which allows us to call parent method: $.magnificPopup.proto.close.call(this); }; // you may override any method like so, just note that it's applied globally } } });
🌐
CodePen
codepen.io › ysnoritnk › pen › VoyJER
magnific-popup-Ajax Type-callbacks
$('.ajax-popup-link').magnificPopup({ type: 'ajax', ajax: { settings: null, cursor: 'mfp-ajax-cur', tError: '<a href="%url%">The content</a> could not be loaded.' }, callbacks: { parseAjax: function(mfpResponse) { mfpResponse.data = $(mfpResponse.data).find('.youtube'); }, ajaxContentAdded: function() { this.content.append("<div>追加したコンテンツ</div>"); } } });
🌐
GitHub
github.com › dimsemenov › Magnific-Popup › issues › 996
Callbacks don't work if a popup was opened from another popup · Issue #996 · dimsemenov/Magnific-Popup
June 24, 2017 - PROBLEM: The Login Popup is cleaned without problems, but the Sign Up Form is not cleaned, because callbacks are not triggered. ... $('#open-login-modal').magnificPopup({ items: { src: '#modal-login', type: 'inline' }, midClick: true, mainClass: 'mfp-fade', callbacks: { afterClose: function() { cleanUpForm($('#login-form')); } } });
🌐
Igem
2017.igem.org › TMMU_China › js › jquery_magnific-popup
TMMU China/js/jquery magnific-popup - 2017.igem.org
November 15, 2013 - if(data.key) { if(!mfp.popupsCache[data.key]) { mfp.popupsCache[data.key] = {}; } mfp.currTemplate = mfp.popupsCache[data.key]; } else { mfp.currTemplate = {}; } mfp.st = $.extend(true, {}, $.magnificPopup.defaults, data ); mfp.fixedContentPos = mfp.st.fixedContentPos === 'auto' ?
🌐
GitHub
gist.github.com › nekoneko-wanwan › e3b52a87b4499df7d478
magnificPopupを使ったポップアップinポップアップを実装 · GitHub
$.magnificPopup.open()でポップアップを表示している場合は、callbackにはinstanceからアクセスする · 最初のポップアップでDOMを生成しているため、.on()でliveイベントを設定 · イベントの重複登録を防ぐため、.onの前に.offを行う ·
🌐
Kriesi
kriesi.at › home › topics › enfold › alert when popup is closed
Alert when popup is closed - Support | Kriesi.at - Premium WordPress Themes
October 1, 2018 - <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...
🌐
GitHub
github.com › dimsemenov › Magnific-Popup › issues › 707
Callback for prev / next Element? · Issue #707 · dimsemenov/Magnific-Popup
August 7, 2015 - I want to call a trigger a prev / next function when mfp slides an element. Therefore I tried to use the "change" callback - but the problem is that this callback also triggers when the popup gets opened, also the "direction" is set to "...
Author   uncenteredDiv
🌐
Envato Forums
forums.envato.com › envato authors › theme authors
Nested Modal using Ajax (Magnific Popup) - Envato Forums
January 10, 2017 - Hi All, Can you help me on this jquery issue I have? How do you add a nested modal using Magnific Popup? A link that shows modal inside a modal using Ajax. here’s my code below. main HTML Link One when a Link One is click it will show modal ajax… when modal shows there is a link inside, ...