Im using the colorbox and colorbox_node module. Out of the box you have to specify a fixed height for the overlay. However I want the overlay to be the same height as its content.
This can be done with $.colorbox.resize. The issue is that it doesnt work if I call it on cbox_complete. The reason is that cbox_complete happens before the content is loaded with AJAX, so its as if there is no content and the height is set to 0 (plus padding).
Ive got it working with the following. Its not a great solution, Its not completely robust and the time delay before the resize isnt an ideal user experience.
$(document).bind('cbox_complete', function(){
setTimeout($.colorbox.resize,1000);
});
UPDATE - I dont know if its best practice (I expect not) but the following placed in the tpl file works:
UPDATE 2 - I spoke too soon. This screws up in IE8 (im not testing on 7 or 6). For one node the 'x' to close the overlay is missing. For the other node only the top 20px or so of the overlay is visible.
<script type="text/javascript">
(function($) {
Drupal.behaviors.global_custom_two = {
attach : function(context, settings) {
$.colorbox.resize();
}
}})(jQuery);
</script>