The file I'm loading into the modal dialog can vary in height. When the first link is opened, the top of the dialog is centered horizontally (meaning the dialog is positioned too low). After I close this and reopen again, with either the same edit button or a different one, the positioning is better.
It seems like it's always one step behind: the first load it can't tell what the width/height is of the file being loaded, then on a subsequent load of the same file, it's positioned perfectly.
I'm using the following code as a modal edit for a data table:
$(".editMe").button({
icons: {
primary: 'ui-icon-document'
},
text: false
}).click(function () {
var eventLink = $(this).attr("name");
var dialogOpts = {
title: "Make Modifications or Delete This Event",
modal: true,
autoOpen: false,
height: "auto",
width: "auto",
open: function () {
//The height of the file below can vary, and in the
//JS Bin environment the dialog loads just fine blank
$("#modify").load("themes_edit.asp?id=" + eventLink);
},
close: function () {
oTable.fnDraw();
}
};
$("#modify").dialog(dialogOpts).dialog("open");
return false;
});
And here's some sample HTML (though the file loaded into #modify isn't live). I've also set this up at JS Bin.
<html>
<head>
<link class="jsbin" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1/themes/base/jquery-ui.css" rel="stylesheet" type="text/css" />
<script class="jsbin" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script class="jsbin" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.0/jquery-ui.min.js"></script>
<link class="jsbin" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1/themes/base/jquery-ui.css" rel="stylesheet" type="text/css" />
</head>
<body>
<button class="editMe" name="2810">edit</button>
<button class="editMe" name="2811">edit</button>
<button class="editMe" name="2812">edit</button>
<button class="editMe" name="2813">edit</button>
<div id="modify"></div>
</body>
</html>