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

How to generate a (magnific popup)-gallery without a-tags
Add data to items in Magnific Popup
How to set the divs to make Magnific Popup animations work
how to display map in mobile devices using magnific popup?
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

Categories

HOME
clips
jsp-tags
adb
amazon-ecs
youtube-api-v3
frameworks
ravendb
bs4
google-translate
event-handling
django-simple-history
aurigma
lucene.net
amazonsellercentral
ml
cloudhub
devops
hammerspoon
rundeck
opennlp
nhapi
ejabberd-module
gsmcomm
directx-10
ecto
key-value-observing
titanium-mobile
karaf
google-sites-2016
google-qpx-express-api
wallpaper
wpf-controls
host
overlap
vxworks
simplexml
automake
gesture
vapor
password-encryption
import-from-excel
hibernate-tools
react-scripts
jquery-validate
composite-key
lync-client-sdk
account-kit
google-cdn
pintos
elements
lua-5.1
superstack
bgp
hexdump
hsv
maven-tomcat-plugin
libressl
remobjects
streambase
python-green
fscommand
xc16
asp.net-dynamic-data
google-reader
sgen
uitouch
poller
seaside
page-layout
aqtime
file-locking
eclipse-memory-analyzer
yui-compressor
free-variable
hosts-file
enter
postgresql-performance
amazon-appstore
winbugs14
radcombobox
gacutil

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