dimsemenov / Magnific-Popup

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

How do you call the iframe popup when its loaded dynamically #1031

Open Chijioke11 opened 7 years ago

Chijioke11 commented 7 years ago

When a DOM content containing a popup-webcam class is loaded on the webpage dynamically, how do delegate the event so it still works as normal.

//getting present and future DOM element
$(document).on('click', '.popup-webcam', function (e) {

});
//getting only present DOM element on page load
$(document).ready(function() {
$('.popup-webcam').magnificPopup({
disableOn: 0,
type: 'iframe',
mainClass: 'mfp-fade',
removalDelay: 160,
preloader: false,
fixedContentPos: false
});
});
alanpilloud commented 6 years ago

you can use the delegate option :

jQuery(document).magnificPopup({
  delegate: ".popup-webcam",
  type: "iframe",
  //...
});
maciejbogusiak commented 6 years ago

It's not working that way. I got Error: Syntax error, unrecognized expression: https://www.youtube.com/...