动态添加项目到Magnific Popup库 [英] Dynamically add items to Magnific Popup gallery

查看:72
本文介绍了动态添加项目到Magnific Popup库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法在已经打开的 Magnific Popup 中动态添加图库项目? (或更新当前项目)。在插件文档中找不到任何内容。

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.

推荐答案

是的,有可能:

// 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();

关于放入什么 items 数组,请参阅文档 - http://dimsemenov.com/ plugins / magnific-popup / documentation.html#from-the-items-option

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

这篇关于动态添加项目到Magnific Popup库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆