coloraddict
coloraddict

Reputation: 131

error on magnific popup youtube video on page load

I'm finding it difficult to load a YouTube video using magnificpopup.

I could not find any solution on the following reference: how to load magnific popup on page load.

Here's the code:

$(document).ready(function(){
    $.magnificPopup.open({
    disableOn: 700,
    type: 'iframe',
    removalDelay: 160,
    preloader: true,
    fixedContentPos: false,
     iframe: {
        patterns: {
            youtube: {
                index: 'https://youtube.com/', 
                id: 'v=somevideo', 
                src: 'http://www.youtube.com/embed/%id%?autoplay=1' 
            }
        }
    }
});
}); 

I need the video to load on page load. It throws an error stating:

Uncaught TypeError: Cannot read property 'parsed' of undefined

Upvotes: 1

Views: 3090

Answers (1)

Andrzej Doyle
Andrzej Doyle

Reputation: 103817

Why do you expect the code in your question to work? As in, what makes you think that those are a good set of properties to pass to the magnificPopup.open function?

I've had a look at the documentation/examples from http://dimsemenov.com/plugins/magnific-popup/, and I couldn't see an example that involved passing an iframe property.

The example given for a YouTube video attaches handlers to href elements:

$(document).ready(function() {
    $('.popup-youtube, .popup-vimeo, .popup-gmaps').magnificPopup({
        disableOn: 700,
        type: 'iframe',
        mainClass: 'mfp-fade',
        removalDelay: 160,
        preloader: false,

        fixedContentPos: false
    });
});

(along with some styling options to specify what the mfp-fade class should look like). So from what I can see, you're just calling the method incorrectly.

Upvotes: 1

Related Questions