Search code examples
javascriptjquerycolorbox

Colorbox resize not working, returns "TypeError: $.fn.colorbox is undefined"


I am using colorbox version 1.3 and called colorbox with a following code

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

As you can see I have called resize method on complete but it gives me following error

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

$.fn.colorbox.resize();

I have also tried the following:

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

$('.extractImages').colorbox.resize();

Solution

  • Have you tried

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