6

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.

Marvin3
  • 5,741
  • 8
  • 37
  • 45

1 Answers1

9

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

Matthias Wiehl
  • 1,799
  • 16
  • 22
Dmitry Semenov
  • 4,566
  • 2
  • 36
  • 39
  • 5
    Is it possible to update/reinit items from html items when they are updated (e.g. images added)? – clime Feb 06 '14 at 15:35