You need to specify height: 'auto' to customize the dialog based on its contents.
.dialog({ height: 'auto', });
@ jon3laze The default value for "position" is "center", so there is no need to set it in the open callback function.
@eagerMoose No need to call
$("#dialog").dialog('open');
because there is an autoOpen option in the dialog box, which defaults to true and the dialog opens immediately after creating the instance. The second call to .dialog ('open') is ignored.
EDIT: Since the download is asynchronous, the dialog is probably initialized before the contents are loaded. Try to initialize the dialog at the end of the download.
$(document).ready(function(){ $(a).click(function(){ $("#dialog").load($(this).attr('href'), function(){ $(this).dialog({ modal: true, width: 400 }); }); }); });
source share