dimsemenov / Magnific-Popup

Light and responsive lightbox script with focus on performance.
http://dimsemenov.com/plugins/magnific-popup/
MIT License
11.38k stars 3.49k forks source link

modal unexpectedly closing on content click #463

Open arjunmenon opened 10 years ago

arjunmenon commented 10 years ago

Hey The modal seems to close when clicked on the content. I specifically put the closeOnContentClick: false,' but still it does not work.

i tried removing all other js from my app to find out of any conflicts, but still the same. also, can bootstrap 3 cause any issue. using jquery version - 1.10.2 its a rails app

 <a class="simple-ajax-popup-align-top" href="/places/first.html" >Load content via ajax</a><br/>
 <a class="simple-ajax-popup" href="/places/second.html" >Load another content via ajax</a>
<script type="text/javascript">
      $(document).ready(function() {

        $('.simple-ajax-popup-align-top').magnificPopup({
          type: 'ajax',

          closeOnContentClick: false,
          closeBtnInside: true,
          overflowY: 'scroll' // as we know that popup content is tall we set scroll overflow by default to avoid jump
        });

        $('.simple-ajax-popup').magnificPopup({
          type: 'ajax',
          closeOnContentClick: false
        });

      });
</script>

UPDATE- I stripped all custom js(not jquery) and css(even bootstrap) from my file. Still it wont work.

asdsadas33 commented 10 years ago

hi! i have no idea about your problem, sorry, but do you know something about mine? https://github.com/dimsemenov/Magnific-Popup/issues/467 can you look at it plz?

bitxl commented 10 years ago

Maybe this can help you, but I just figured out that if you give .mfp-content a padding and you click within that padding it registers this as if you're clicking outside the popup (the root element of the popup is considered content)... I do not understand this decision at all...

nhanaswigs commented 9 years ago

I got that issue and I fixed it Modify this line of code // if click is outside the content if( (target !== mfp.content[0] && !$.contains(mfp.content[0], target)) ) {

to // if click is outside the content if( (target !== mfp.content[0] && !$.contains(mfp.content[0].parentElement, target)) ) {