How can I dynamically resize the jQuery Colorbox plugin?

前端 未结 16 1646
情书的邮戳
情书的邮戳 2020-12-13 14:14

The AJAX content loaded in a Colorbox has some JavaScript included that resizes things within the content. Colorbox determines its sizing based on the sizes before all of th

16条回答
  •  温柔的废话
    2020-12-13 14:47

    Chris's answer got me halfway there but it caused a massive error in IE7/8 as it will call that function everytime the window resizes and even strangely on some asp.net buttons that cause a postback?!?! even when there isn't an active colorbox.

    This seems to solve it:

        $(window).resize(function(){
                   if ($('#colorbox').length) {
         if( $('#colorbox').is(':hidden') ) {                    
              }
             else {
               $.fn.colorbox.load();
             }
           }
        });
    

    It checks that #colorbox exists using .length, and then checks that it's not hidden which does the trick as I could see in Firebug that when you close the colorbox it isn't fully removed/destroyed just hidden!

    Hope this helps..

提交回复
热议问题