Colorbox调整大小不起作用,返回“TypeError:$ .fn.colorbox is undefined”

问题描述 投票:0回答:4

我正在使用colorbox 1.3版,并使用以下代码调用colorbox

 $(".extractImages").colorbox({
    ajax:true,
    speed:100,
    initialWidth:'110px', 
    initialHeight:'85px',
    rel:'popup',
    fixed:true,
    arrowKey:false,
    href:function(){ 
        return $(this).attr('popup'); 
    },
    onLoad: function() {
        $('#cboxClose').html('');
        $('#cboxCurrent').remove();
        $('#cboxNext').remove();
        $('#cboxPrevious').remove();
        $('#cboxTitle').remove();
    },  
    onComplete : function() {
        $('#cboxClose').html('<img class="popupClose" src="/public/images/close.png"/>');
        $.fn.colorbox.resize();             
    }
  });

如你所见,我已经完成调用resize方法,但它给了我以下错误

TypeError: $.fn.colorbox is undefined
[Break On This Error]   

$.fn.colorbox.resize();

我也尝试过以下方法:

TypeError: $(".extractImages").colorbox is undefined
[Break On This Error]   

$('.extractImages').colorbox.resize();
javascript jquery colorbox
4个回答
1
投票

你有没有尝试过

onComplete : function() { 
$(this).colorbox.resize(); 
}  

2
投票

Documentation在“公共方法”下说:$ .colorbox.resize()。我会放手一搏。


1
投票

你确定加载了colorbox吗?看起来你没有在页面上包含jquery.colorbox.js。这个$.colorbox必须在控制台中显示function()


0
投票
$(window).resize(function(){
        $.colorbox.resize({
            maxWidth:"auto",
            width:95+'%',
        });
});
© www.soinside.com 2019 - 2024. All rights reserved.