【问题标题】:how do I open fancybox using the specific index of an image如何使用图像的特定索引打开 fancybox
【发布时间】:2013-04-20 14:04:27
【问题描述】:

我正在使用带有以下代码的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中给出索引?

【问题讨论】:

  • 如何获得索引?你的点击事件处理程序在哪里?
  • 你不需要传递任何index,fancybox 只会打开你点击的链接的href 上设置的目标图像,除非你有一个处理程序来修改这种默认行为。
  • 我有同样的问题,因为我在我的移动应用程序中绕过点击事件!

标签: javascript jquery .net indexing fancybox


【解决方案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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-12-06
    • 1970-01-01
    • 2013-09-09
    相关资源
    最近更新 更多