我正在使用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();
你有没有尝试过
onComplete : function() {
$(this).colorbox.resize();
}
Documentation在“公共方法”下说:$ .colorbox.resize()。我会放手一搏。
你确定加载了colorbox
吗?看起来你没有在页面上包含jquery.colorbox.js
。这个$.colorbox
必须在控制台中显示function()
。
$(window).resize(function(){
$.colorbox.resize({
maxWidth:"auto",
width:95+'%',
});
});