Skip to content

Instantly share code, notes, and snippets.

@amurrell
Last active December 16, 2022 12:35
Show Gist options
  • Save amurrell/0b78cccf0e1554846d50 to your computer and use it in GitHub Desktop.
Save amurrell/0b78cccf0e1554846d50 to your computer and use it in GitHub Desktop.
MagnificPopup Open - not from a link
// If you do not want to open a popup from a user clicking a button,
// and your popup container is already on the page (footer?) hidden...
$.magnificPopup.open({
items: {
src: $('#modal-container')
},
type: 'inline',
mainClass: 'mfp-fade'
});
// If you want to make your own close button...
$.magnificPopup.open({
items: {
src: $('#cta-funnel-travel')
},
callbacks: {
open: function(){
// this.content is your modal div ID, jquery object.
this.content.find('.your-button').click(function(){
$.magnificPopup.close();
});
}
},
type: 'inline',
mainClass: 'mfp-fade',
// closeOnBgClick: false, // Disable bg click to close
// showCloseBtn: false, // Disable the top corner close button
modal: true // short cut to disabling the background close, content close, escape close etc, top corner close
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment