How can I dynamically resize the jQuery Colorbox p

2020-02-07 21:23发布

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 the AJAX happens. How can I make the Colorbox resize after the content has been loaded?

Here is a link where someone said that you can call colorbox() again after it's been loaded, but I can't figure out how to do that:

http://groups.google.com/group/colorbox/browse_thread/thread/535d21c69e9006b0

16条回答
霸刀☆藐视天下
2楼-- · 2020-02-07 22:00
$(window).resize(function(){    
        $.colorbox.resize({
            maxWidth:"auto",
            width:95+'%',
        });
});
查看更多
3楼-- · 2020-02-07 22:02

You can call it in a callback function it provides:

$(".single").colorbox({}, function(){
     alert('Howdy, this is an example callback.');
});
查看更多
▲ chillily
4楼-- · 2020-02-07 22:03

Well, I haven't used Colorbox before but I have used similar things, and if I understand correctly, what you need it to do is change the style of the box after something's been loaded.

If you find what id/class values are applied to the Colorbox, you could make it so that when the AJAX content is loaded, a function is called to change the style of the appropriate part of the Colorbox.

查看更多
在下西门庆
5楼-- · 2020-02-07 22:05
$.colorbox.resize()

This will also work on the active colorbox if you don't happen to know the selector for the active colorbox.

查看更多
登录 后发表回答