我正在使用带有以下代码的fancybox
$("a[rel=Fancy" + UserId + "].Items").fancybox({ 'autoscale': 'false',
'cyclic': true,
'transitionIn': 'elastic',
'transitionOut': 'elastic',
'titlePosition': 'over',
'titleFormat': function(title, currentArray, currentIndex, currentOpts) {
return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' ' + title : '') + '</span>';
}
});
$("a[rel=Fancy" + UserId + "].Items:first").click();
它打开fancybox,但它开始显示第一个索引的图像。我想在用户点击的图像上启动fancybox ...
如何在fancybox中提供索引?
答案 0 :(得分:1)
var hrefList = new Array;
for (var i in data) {
hrefList[i] = data[i].PATH
}
$("ul.gallery a").each(function(e){
$(this).click(function(){
$.fancybox( hrefList, {
index: e,
type: 'image'
}); //fancybox
});//click
});//each