我为我们产品的照片库使用jQZoom(插件,版本2.3)。在产品页面上,用户可以选择根据所选属性重新加载图像的产品中的不同属性。用户可以在初始页面加载时轻松点击缩略图,但是当他们选择一个属性时,通过AJAX刷新的照片和缩略图不再是可点击的。下面是一些代码我的工作:通过AJAX重新加载后无法点击的缩略图
这部分被称为页面加载,当一个新的产品属性选择:
function findProductPhotos(attributeDetailID) {
if(typeof attributeDetailID != "undefined" && attributeDetailID > 0) {
$.ajax({
cache: false,
data: {
method: 'getAttributeDetailImages',
productAttributeDetailID: attributeDetailID
},
dataType: 'json',
success: function(data) {
updateProductPhotos(data);
},
traditional: true,
type: "GET",
url: "/com/ei/image/ImageProxy.cfc"
});
}
}
被检索到的图像后,该功能被称为:
function updateProductPhotos(data) {
// if images where returned, then update the main photo and thumbnail
if(data.length > 0) {
// remove all existence of jqzoom so we can reassign it correctly w/o error
$(".jqzoom").unbind().removeData('jqzoom').empty();
$(".zoomPad").remove();
// remove all the current thumbnails
$('#thumblist').empty();
// put back all the new thumbnails and main product image
$(data).each(function(i,objImg) {
// if this is the first image, replace the main image with it
if (i==0) {
var mainProdImgElem = $('<img id="mainProdImg" width="350" />');
$(mainProdImgElem).attr('src',objImg.srcHiRes);
$(mainProdImgElem).appendTo('.jqzoom');
$('.jqzoom').attr('href',objImg.srcHiRes);
$('.zoomWrapperImage').find('img').attr('src', objImg.srcHiRes);
}
var elemThumb = $('<li><a href="javascript:void(0);"><img width="75" border="0" /></a></li>');
if (i==0) {
$(elemThumb).find('a').addClass('zoomThumbActive');
}
$(elemThumb).find('img')
.attr('src', objImg.srcThumb)
.attr('rel', '{gallery: \'gal1\', smallimage: \'' + objImg.srcHiRes + '\', largeimage: \'' + objImg.srcHiRes + '\'}');
$(elemThumb).appendTo('#thumblist');
});
// rebind jqzoom
$(".jqzoom").jqzoom(jqZoomOptions);
}
}
和包含HTML代码片段缩略图:
<ul class="clearfix" id="thumblist">
<cfloop query="qimages">
<cfset variables.Thumbnail = imageObj.getImageSrc(
imageID = imageID,
size = "thumbnail")>
<cfif FileExists(ExpandPath(hiresFilename))>
<cfset zoomerFile = hiresFilename />
<cfelse>
<cfset zoomerFile = largeFilename />
</cfif>
<li>
<a href="javascript:void(0);" <cfif currentrow eq 1>class="zoomThumbActive" rel="{gallery: 'gal1', smallimage: '#zoomerFile#', largeimage: '#zoomerFile#'}">
<img src="#variables.Thumbnail#" width="75" border="0">
</a>
</li>
</cfloop>
</ul>
任何想法为什么会发生这种情况或如何解决?