Having looked into Make JQuery UI Dialog automatically grow or shrink to fit its contents, I am using the height: \"auto\"
option when building a jQuery modal dialo
This is 4 years Late but i have the same problem.
Wrote code that fixed it
Put a unique class on your dialog:
dialogClass:"someClassName"
$(".someClassName").resize(function () {
var totalHeight = 0;
var children = $(".someClassName").children(); //get all divs inside the dialog
for (var i = 0; i < children.length; i++) {
if ($(children[i]).innerWidth() > 15) {
var childrenHeight = children[i].scrollHeight;
totalHeight += childrenHeight;//make sure your dialog will be the correct height
}
}
$("#idOfContentWithWrongHeight").innerHeight($("#idOfContentWithWrongHeight")[0].scrollHeight);//put the content at the height it should appear
$(".someClassName").height(totalHeight);//update the height of the dialog
});
Here is the sample demo
$( "#dialog-message" ).dialog({
modal: true,
height: "auto",
buttons: {
Ok: function() {
$( this ).dialog( "close" );
}
}
});
setTimeout(function() {
$('#inside').append("Hello!<br>");
setTimeout(arguments.callee, 1000);
},1000);
That is very strange... I'm not sure how helpful this will be, but I did manage to get the auto-height to work with the following code:
<html>
<head>
<link href="jqueryUI/css/ui-lightness/jquery-ui-1.8.19.custom.css"
rel="stylesheet" type="text/css">
<script src="jquery-1.7.1.js"></script>
<script src="jqueryUI/js/jquery-ui-1.8.19.custom.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$("#dialog").dialog({
autoOpen: false,
width: "400",
height: "auto",
show: "slide",
modal: true,
buttons: {
Ok: function() {
$( this ).dialog( "close" );
}
}
});
$("#dialog").dialog('open');
});
</script>
</head>
<body>
<div id="dialog">
1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />
</div>
</body>
</html>
It's basically using the same structure you've already established.
This all I have done for the dialog box to grow automatically
$("#edit_dependent").dialog({
autoOpen:false,
modal:true,
width:800,
position:["center",20],
minHeight:"auto"
});