Dynamically add items to Magnific Popup gallery

限于喜欢 提交于 2019-12-10 14:53:02

问题


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.


回答1:


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



来源:https://stackoverflow.com/questions/19835069/dynamically-add-items-to-magnific-popup-gallery

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!