2011-09-07 57 views
1

我在jquery ajax实时内容上使用这个jQuery代码来处理lightbox。但我想显示下一个和预览按钮。现在只显示图片和关闭按钮。我能怎么做?

$('a[rel=gallery]').live('click', function() { 
    url = this.href; // this is the url of the element event is triggered from 
    $.fn.colorbox({href: url}); 
    return false; 
}); 

回答

0

只能看到图像和关闭按钮的原因是因为彩盒尚未涉及表示图像一系列对象的jQuery集合。

也就是说,如果ColorBox只显示一个图像,他会隐藏Prev和Next UI元素。

我们不能告诉你所提供的更多东西,但不知何故,它看起来像你只给他一张图片。

如果在第一次加载页面后通过Ajax获取新图像,则可以考虑将ColorBox作为Ajax成功回调的一部分进行重新引导。

  • 凯文中号
2

您可以使用这就是代码:

$('a[rel="gallery"]').live('click', function(){ 
    var $this = $(this); 
    var rel = $this.attr('rel'); 

    // Build colorbox sequence 
    $this.closest('div').find('a[rel="'+rel+'"]').colorbox({ // find all matching items & init colorbox on them 
       open: false, // don't open, just init 
       rel: rel // use the rel 
    }); 

    // Open the specific link's colorbox 
    $this.colorbox({open: true}); 
    return false; // prevent 
});