Magnific-Popup icon indicating copy to clipboard operation
Magnific-Popup copied to clipboard

Loading images via Ajax

Open jaimestuardo opened this issue 5 years ago • 0 comments

Hello, I want just load a gallery of images from Ajax.

I tried this code:

        $('.popup-pic').magnificPopup({
                    type: 'ajax',
                    callbacks: {
                        parseAjax: function (mfpResponse) {
                            // mfpResponse.data is a "data" object from ajax "success" callback
                            // for simple HTML file, it will be just String
                            // You may modify it to change contents of the popup
                            // For example, to show just #some-element:
                            // mfpResponse.data = $(mfpResponse.data).find('#some-element');

                            // mfpResponse.data must be a String or a DOM (jQuery) element

                            console.log('Ajax content loaded:', mfpResponse);
                        },
                        ajaxContentAdded: function () {
                            // Ajax content is loaded and appended to DOM
                            console.log(this.content);
                        }
                    }
                });

And the URL is a URL that loads the list this way:

 items
         src: path1,
         src: path2,
         src: path3

That's all, but the only message I get is "TypeError: context is undefined".

Is the plugin prepared for this? if not, you could consider adding this in the future.

Thanks Jaime

jaimestuardo avatar May 20 '19 17:05 jaimestuardo