I have a form that opens up on a popup and have added a custom close button
next to a submit button.
This is a jQuery I am using for the close button:
$(document).ready(function() {
$('#close').click(function() {
$.magnificPopup.close();
});
});
However this does not seem to work. Does anyone know how to do this?
The easiest way to use react-magnific-popup is to install it from NPM and include it in your own React build process (using Browserify, Webpack, etc). You can also use the standalone build by including dist/react-magnific-popup. js in your page.
Magnific Popup is a fast, light, mobile-friendly and responsive lightbox and modal dialog jQuery plugin. It can be used to open inline HTML, ajax loaded content, image, form, iframe (YouTube video, Vimeo, Google Maps), and photo gallery. It has added animation effects using CSS3 transitions.
Some of these answers work, but it depends on your implementation of the popup. If you're still having trouble, I'd suggest using the callback method to ensure consistency:
$.magnificPopup.open({
items: {
src: $domElement,
type: 'inline'
},
callbacks: {
open: function() {
$('#close-btn').on('click',function(event){
event.preventDefault();
$.magnificPopup.close();
});
}
}
});
Hope this helps!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With