开发者

Jquery colorbox grouping problem on $.live()

i'm using this jquery code for lightbo开发者_C百科x on jquery ajax live content. But i want to show next and preview buttons. Now only shows picture and close button. How can i do?

  $('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;
 });


You can use thats code:

$('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
});


The reason you only see the image and a close button is because ColorBox hasn't been related to a jquery collection of objects representing a series of images.

That is, if ColorBox only has one image to show, he hides the Prev and Next UI elements.

We can't tell much more from what you've provided, but somehow it looks like you feeding him only the one image.

If new images are acquired via Ajax after the page is first loaded, you may consider reiniting ColorBox as part of an Ajax success callback.

  • Kevin M
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜