关于为什么这不会在页面更改时分离我的“homeSlider”照片擦除实例的任何想法?我想我正在关注Photoswipe文档,但它似乎没有分离实例。我正在使用Jquery mobile,因此是“pageshow”/“pagehide”。当我回到页面并且幻灯片冻结时,它会抛出此错误:“Code.PhotoSwipe.activateInstance:无法激活实例,因为另一个实例已经为此目标激活”
(function(window, Util, PhotoSwipe){
$(document).ready(function(){
$('#home').live('pageshow', function(e){
var
currentPage = $(e.target),
homeSlider;
homeSlider = PhotoSwipe.attach(
window.document.querySelectorAll('#slider a'),
{
target: window.document.querySelectorAll('#PhotoSwipeTarget')[0],
loop: true,
preventHide: true,
autoStartSlideshow: true,
captionAndToolbarHide: true,
margin: 0,
}
); // PhotoSwipe.attach
homeSlider.show(0);
return true;
});
$('#home').live('pagehide', function(e){
var
currentPage = $(e.target),
homeSlider = PhotoSwipe.getInstance(currentPage.attr('id'));
if (typeof homeSlider != "undefined" && homeSlider != null) {
PhotoSwipe.detatch(homeSlider);
}
return true;
});
}); // $(document).ready(function(e){
}(window, window.Code.Util, window.Code.PhotoSwipe)); // function(window, util, PhotoSwipe)