我在使用 photoswipe 的列表图片中附加图片时遇到问题。jquery 移动页面使用类gallery-page 将在一个漂亮的查看器中打开它。我尝试使用附加功能将更多图片添加到图片列表中。这很好用,只是问题是当我单击图像时,它不会在漂亮的查看器中打开它。我认为这与类画廊页面有关。在某种程度上,jquery 添加的图片找不到类画廊页面。我能做些什么?
这是页面的样子:
HEAD 中的 Javascript:
<script type="text/javascript">
/*
* IMPORTANT!!!
* REMEMBER TO ADD rel="external" to your anchor tags.
* If you don't this will mess with how jQuery Mobile works
*/
(function(window, $, PhotoSwipe){
$(document).ready(function(){
$('div.gallery-page')
.live('pageshow', function(e){
var
currentPage = $(e.target),
options = {},
photoSwipeInstance = $("ul.gallery a", e.target).photoSwipe(options, currentPage.attr('id'));
return true;
})
.live('pagehide', function(e){
var
currentPage = $(e.target),
photoSwipeInstance = PhotoSwipe.getInstance(currentPage.attr('id'));
if (typeof photoSwipeInstance != "undefined" && photoSwipeInstance != null) {
PhotoSwipe.detatch(photoSwipeInstance);
}
return true;
});
});
}(window, window.jQuery, window.Code.PhotoSwipe));
</script>
正文中的页面:
<div data-role="page" data-add-back-btn="true" id="Gallery" class="gallery-page" >
<div data-role="header">
<div data-role="navbar">
<ul>
<li><a href="#spots" data-transition="none" data-direction="reverse"><img src="images/m1.png"/></a></li>
<li><a href="#addspots_page1" data-transition="none" data-direction="reverse"><img src="images/m2.png"/></a></li>
<li><a href="#internetspots" data-transition="none" data-direction="reverse"><img src="images/m3.png"/></a></li>
</ul>
</div><!-- /navbar -->
<h2>Extra information</h2>
</div><!-- /header -->
<div data-role="content">
<ul class="gallery" id="pictures" >
<!-- is necessery because photoswipe can't have null images -->
<li class="s1"><a href="images/no_photo.jpg" rel="external"><img src="image1.jpeg" alt="Image 001" /></a><p>s1</li>
</ul>
</div>
</div>
用jquery附加图片:
$("#pictures").append('<li class="s2"><a href="image2.jpeg" rel="external"><img src="image2.jpeg" alt="Image 001" /></a></li>'</li>')