7

I've just recently implemented the 'Magnific Popup' and the popup comes up fine, however when I click an input box the entire popup disappears back to the parent page. On the examples shown on the plugin website, the entire dialog box is clickable until you click outside of that box.

I'm hoping its just something extremely simple I've missed, but it's still doing my head in.

I really appreciate any help I can get!

Thanks :)

Frank
  • 71
  • 1
  • 3
  • 1
    Yes, you have missed something extremely simple, please post some code! No-one can really answer your question without seeing what you have tried. – Ken Y-N May 17 '13 at 02:24
  • Hi @KenY-N, The CMS is Websitebaker so its literally just a piece of PHP that links to a WYSIWYG page. I read on https://github.com/dimsemenov/Magnific-Popup/pull/39 that you need to "loop the nodes" but I dont know how to do that exactly. – Frank May 17 '13 at 03:20

5 Answers5

9

If you're using "ajax" content type, you need to make sure that you've got only one root node.

http://dimsemenov.com/plugins/magnific-popup/documentation.html#ajax_type

E.g., this is correct contents of ajax file:

<div>
    html content
    <script src="something.js"></script>
</div>

Incorrect:

<script src="something.js"></script>
<div>
    html content
</div>

Incorrect:

<div>
    html content
</div>
<div>Another content</div>

Also make sure that closeOnContentClick is set to false http://dimsemenov.com/plugins/magnific-popup/documentation.html#closeoncontentclick

If, for whatever reason, you can't change the contents of ajax file, you may parse content in parseAjax callback, like described here (so the mfpResponse.data contains only one root node).

Dmitry Semenov
  • 4,566
  • 2
  • 36
  • 39
1

I can't reply yet (too low rep..) so adding it like this: seems that this also counts for type: 'inline'. Safe to always wrap content by a div..

$.magnificPopup.open({
  items: {
    src: '<div>'+ html +'</div>'
  },
  type: 'inline',
  closeOnContentClick: false
}, 0);
publicJorn
  • 2,404
  • 1
  • 20
  • 30
1

I had the same error. Turned out to be a dumb mistake from my side, i had the same class on my opener and my inline div.

<a href="#popup" class="dialog">Open</a>
<div id="popup" class="dialog mfp-hide"></div>

Of course they needed to be different classes like so:

<a href="#popup" class="dialog">Open</a>
<div id="popup" class="dialog-box mfp-hide"></div>
Christian Werther
  • 336
  • 1
  • 2
  • 12
0

Dmitry explains the problem here https://github.com/dimsemenov/Magnific-Popup/issues/34

Dean Oakley
  • 5,366
  • 2
  • 18
  • 14
0

Add modal:true in the magnificPopup:

$('.your_class').magnificPopup({
    type: 'ajax',
    modal:true
});
Vasfed
  • 18,013
  • 10
  • 47
  • 53
Manik Thakur
  • 294
  • 2
  • 15