Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/search/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
$.live()上的Jquery colorbox分组问题_Jquery_Lightbox_Colorbox - Fatal编程技术网

$.live()上的Jquery colorbox分组问题

$.live()上的Jquery colorbox分组问题,jquery,lightbox,colorbox,Jquery,Lightbox,Colorbox,我在jQueryAjax live内容上使用这个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 fals

我在jQueryAjax live内容上使用这个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;
 });

之所以只看到图像和关闭按钮,是因为ColorBox与表示一系列图像的jquery对象集合没有关联

也就是说,如果ColorBox只有一个图像要显示,那么他会隐藏上一个和下一个UI元素

我们无法从你提供的信息中看出更多,但不知何故,你似乎只给了他一张图片

如果在第一次加载页面后通过Ajax获取新的图像,可以考虑将彩盒作为Ajax成功回调的一部分。

  • 凯文M

您可以使用以下代码:

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