Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to close magnific popup by jquery

I m using magnific popup in my project. To close this popup by jquery I am using $('.mfp-close').click(); and it's working but I have need to close by another way. Plz help me if any other way. Thanks in advance

like image 536
Sanjay Avatar asked Jun 04 '13 07:06

Sanjay


People also ask

How do I add a pop up to Magnific using jQuery?

Since the Magnific is a plugin of the jQuery framework, it needs to reference the jQuery library. This can be done by using the Google-hosted version of jQuery or downloading and using the distribution files. Include CSS: Add the magnific-popup.css file from the dist folder of Magnific.

How do I Close a magnific pop up?

These are some ways you can close this pop up: var magnificPopup = $.magnificPopup.instance; // save instance in magnificPopup variable magnificPopup.close (); // Close popup that is currently opened

How to prevent popup from closing when Click on X button?

enableEscapeKey: if it is true, the popup will close when click the escape key. To prevent this, assign the value false to close only when click on X (close) button in top right cornor of popup. By defualt, true is assigned for this.

Does Magnific Popup work with Lightbox?

The majority of lightbox plugins require you to define size of it via JS option. Magnific Popup does not - feel free to use relative units like EM's or resize lightbox with help of CSS media queries. Update content inside lightbox without worrying about how it'll resize and center.


3 Answers

Just use $.magnificPopup.close()

like image 63
Konstantine Kalbazov Avatar answered Oct 19 '22 11:10

Konstantine Kalbazov


try this:

var magnificPopup = $.magnificPopup.instance; 
// save instance in magnificPopup variable
magnificPopup.close(); 
// Close popup that is currently opened
like image 41
Bobby5193 Avatar answered Oct 19 '22 12:10

Bobby5193


Take a look here http://dimsemenov.com/plugins/magnific-popup/documentation.html#api

These are some ways you can close this pop up:

var magnificPopup = $.magnificPopup.instance; // save instance in magnificPopup variable
magnificPopup.close(); // Close popup that is currently opened

or

$.magnificPopup.close();

or

$('your-selector').magnificPopup('close');

For me, only the third one worked efficiently.

like image 15
Lem Avatar answered Oct 19 '22 11:10

Lem