Colorbox会加载以前的所有颜色框

时间:2013-08-29 21:09:17

标签: jquery drupal drupal-7 colorbox

我创建了一个彩盒,它工作正常。问题是,当我关闭它并在页面上打开一个不同的颜色框时,两个颜色框都会加载(第一个颜色框直接在第二个颜色框后面)。当我关闭它们并打开另一个时,我会得到三个彩盒等等。

我在Drupal 7视图中这样做,我正在为所有图像字段添加colorbox链接。

我调用彩盒的代码:

$('。views-field-field-gallery-images .field-content img')。each(function(){

    nid = $(this).parent().parent().parent().find('.views-field-nid .field-content').html();
    href = $(this).attr('href');
    //$(this).attr('href', 'gallery-slideshow/' + nid +'?width=500&height=500&iframe=true');
    href = 'gallery-slideshow/' + nid;
    $(this).colorbox({href: href});
    //$(this).attr('href', 'http://www.cnn.com?width=500&height=500&iframe=true');
    //$(this).addClass('colorbox-load init-colorbox-load-processed cboxElement');
});

1 个答案:

答案 0 :(得分:0)

在你的colorbox中使用它:

var x = $(this).colorbox({onClosed: function(){ x.remove(); }});