0
我正在與一個項目的朋友合作,並且我們無法確定在點擊查看圖庫後如何重新初始化。有什麼想法嗎?提供的代碼︰加載照片庫後初始化flexslider
jQuery(document).ready(function(){
fetchAlbumList();
});
function fetchAlbumList() {
jQuery.ajax({
url:'https://picasaweb.google.com/data/feed/api/user/107232985562777672515' + '?alt=json&callback=?',
dataType:'json',
success:function(data){
var albumList = '';
for (var i = 0; i < data.feed.entry.length; i++) {
albumList += '<li class="onethird column"><div class="pod"><div class="podContent">';
albumList += '<img src="' + data.feed.entry[i].media$group.media$content[0].url + '"/>';
albumList += '<h2>' + data.feed.entry[i].media$group.media$title.$t + '</h2>';
albumList += '<a href="javascript:void(0)" onclick="fetchAlbum("' + data.feed.entry[i].id.$t + '")" class="button">View Gallery</a>';
albumList += '</div></div></li>';
};
jQuery('.albumList').html(albumList);
}
});
}
function fetchAlbum(albumID) {
jQuery.ajax({
url:albumID.replace('entry','feed') + '&callback=?',
dataType:'json',
success:function(data){
console.log(data);
jQuery('.albumPhotos').html('');
var photoList = '<ul class="slides">'
for (var i = 0; i < data.feed.entry.length; i++) {
photoList += '<li><img src="' + data.feed.entry[i].content.src + '"/></li>';
};
photoList += '</ul>'
var href = jQuery(this).attr('href');
var albumPhotos = '<h2>' + data.feed.title.$t + '</h2>';
albumPhotos += '<div class="sliderWrapper"><div id="slider2" class="flexslider">';
albumPhotos += photoList;
albumPhotos += '</div><div id="carousel2" class="flexslider">';
albumPhotos += photoList;
albumPhotos += '</div></div>';
jQuery('.albumPhotos').html(albumPhotos);
jQuery('#carousel2').flexslider({
animation: "slide",
controlNav: false,
animationLoop: false,
slideshow: false,
itemWidth: 210,
itemMargin: 5,
asNavFor: '#slider2'
});
jQuery('#slider2').flexslider({
animation: "slide",
controlNav: false,
animationLoop: false,
slideshow: false,
sync: "#carousel2"
});
}
});
}
只需要幫助如何重新初始化它。我認爲需要開始回調,但我可能是錯的。