Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Magnific Popup: How to add a custom close button inside a popup form?

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?

like image 783
user1448031 Avatar asked Feb 19 '15 00:02

user1448031


People also ask

How do I use Magnific popup in react?

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.

What is Magnific popup CSS?

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.


1 Answers

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!

like image 121
ChongFury Avatar answered Nov 15 '22 19:11

ChongFury