Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dynamically add items to Magnific Popup gallery

Is there any way to dynamically add gallery items in Magnific Popup that is already open? (or update the current item). Can't find anything about in in plugin docs.

like image 545
Marvin3 Avatar asked Nov 07 '13 11:11

Marvin3


1 Answers

Yes, it's possible:

// get instance (after popup was opened)
var mfp = $.magnificPopup.instance;

// modify the items array (push/remove/edit)
mfp.items.push({
    src: "some-image.jpg"
});

// call update method to refresh counters (if required)
mfp.updateItemHTML();

Regarding to what to put in items array, refer to documentation - http://dimsemenov.com/plugins/magnific-popup/documentation.html#from-the-items-option

like image 115
Dmitry Semenov Avatar answered Nov 11 '22 10:11

Dmitry Semenov