magnific-popup


callbacks not firing when opening a magnific popup from another one


I currently have a magnific popup and within that popup i have a link that opens another magnific popup. Something along the lines of:
$('.logbook-entry-details').magnificPopup({
type: 'ajax',
closeBtnInside:true,
closeOnBgClick:false,
closeOnContentClick:false,
callbacks: {
beforeOpen: function () {
$.magnificPopup.close();
},
open: function() {
console.log('Popup open has been initiated');
},
beforeClose: function() {
console.log('Popup before close has been initiated');
},
close: function() {
console.log('Popup close has been initiated');
},
afterClose :function() {
console.log('Popup after close has been initiated');
}
}
});
After reading i found that callbacks on the second popup will not be registered until i close the original popup as opening the new one just replaces the content and actually doesn't recreate a new instance.
I am trying to figure out how i could have my link within my popup close the current popup before calling the code to open the new one so it can register my callbacks.
By the way, the reason I am trying to do this is i want to reopen the original popup after closing my new popup. If you happen to have a better solution please let me know.
So just in case someone needs this answered, i had to add the following code to my new popup.
// a button that closes the popup
$('#cancel-logbook-entry-btn').click(function(){
$.magnificPopup.proto.close.call(this);
});
$.magnificPopup.instance.close = function () {
//code to show the original popup
};
And then in the original popup i had to add otherwise it will never close the popup
$.magnificPopup.instance.close = function () {
// "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);
};

Related Links

Magnific Popup - Counter in Videogallery
how to manually open and close the popup using Magnific-Popup
How to customize arrows and close button?
no closing “X” with inline content
How to prevent close
Magnific-Popup Loading iframe from non-video players URL
Magnific popup - put arrows inside of an image
magnific closeOnContentClick does not work
How can style popup iframe in Magnific Pop-Up?
Gallery with mixed content types
Title for iframe/video in magnific popup
Magnific Popup: Close floats to the right
Calling magnific-popup on button element instead of an anchor
Implement query.magnific-popup.js in dreamweaver cs5. Syntax error in original code
Magnific-popup event binding to popup content
Magnific Popup - Error when opening a you tube video

Categories

HOME
ibm-bluemix
yii2
google-chrome-extension
keras
comparison
relayjs
bpmn
kalman-filter
gis
react-redux
cross-browser
enterprise-library-5
wamp
indesign
uber-api
primary-key
kibana-4
php-7.1
jplayer
alignment
zebra-printers
lombok
graphlab
tostring
apache-metamodel
sms-gateway
dbext
plunker
conemu
ml
autoconf
facebook-instant-articles
web-sql
accessor
dxf
crosstab
fish
wpfdatagrid
elasticsearch-ruby
galsim
google-cloud-endpoints-v2
exuberant-ctags
fog
calibre
openoffice.org
hexo
overriding
gesture
dynamics-crm-2013
service-discovery
hue
powershell-dsc
avconv
prolog-setof
datastax-startup
drupal-6
setter
sqlclient
nxt
angular-cache
azure-sdk
ado.net-entity-data-model
database-optimization
firebaseui
superstack
oauth2client
rhino-servicebus
qdialog
purge
pundit
sframe
drawbitmap
riak-cs
tableau-online
myo
nsight
sonarqube5.1.2
clipperlib
c++03
jscript.net
tt-news
rdl
elliptic-curve
reactfx
hippomocks
comexception
viadeo
oam
tidy
tws
path-separator
mt
runas
uiviewanimation-curve
windows-phone-7.1.1
bigcouch
gcj
file-comparison
asp.net-mvc-areas
infrastructure
suppress
mirah
microsoft-virtualization
temporal-database

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App