2011-09-07 54 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 
});