【问题标题】:How to add images dynamically to Photoswipe? - Overview hidden如何将图像动态添加到 Photoswipe? - 概览隐藏
【发布时间】:2013-04-22 09:03:18
【问题描述】:

我正在尝试将图像动态附加到 Photoswipe。

$('#imgholder').on('tap', function(event){  
  (function(window,PhotoSwipe){                                                                         var                                                                                        options = {
preventHide: true,
getImageSource: function(obj){
return obj.url;
},
getImageCaption: function(obj){
return obj.caption;
}
},
function(){
for (var i = 0; i < images.length-1; i++)
{
instance = PhotoSwipe.attach([{url:images[i]}],options);
}
}
instance.show(0);
}(window,window.Code.PhotoSwipe));
});

我试图避免使用图库标签,因为我不想显示图库概览。我的网址存储在一个简单的数组中。

var images = result.news[index].bilder_url.split("-,-");

是否可以将此数组附加到 photoswipe 或运行一个简单的 for 循环? 还是有不同的方法?

提前谢谢 :)

【问题讨论】:

    标签: jquery mobile photoswipe


    【解决方案1】:
    (function(window, PhotoSwipe){
    var 
       options = {},
       instance = PhotoSwipe.attach( window.document.querySelectorAll('#Gallery a'), options);
       instance.show(1);   
    }(window, window.Code.PhotoSwipe));
    

    这就是诀窍:)

    在 PhotoSwipe 提供的示例中找到。

    【讨论】:

    • 你能解释一下吗,json调用或链接请求到服务器的数据在哪里???/
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-02-20
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多