如何使用图像的特定索引打开fancybox

时间:2013-04-26 11:50:23

标签: javascript jquery .net indexing fancybox

我正在使用带有以下代码的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 ? ' &nbsp; ' + title : '') + '</span>';
        }
    });

$("a[rel=Fancy" + UserId + "].Items:first").click();

它打开fancybox,但它开始显示第一个索引的图像。我想在用户点击的图像上启动fancybox ...

如何在fancybox中提供索引?

1 个答案:

答案 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

来源:Fancybox, when I open group of images and click on next with using “start index” - it's not working normally