Note that there are some explanatory texts on larger screens.

plurals
  1. POjQuery UI Modal Dialog only centered on SECOND load (content from external file)?
    primarykey
    data
    text
    <p>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.</p> <p>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.</p> <p>I'm using the following code as a modal edit for a data table:</p> <pre><code>$(".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; }); </code></pre> <p>And here's some sample HTML (though the file loaded into #modify isn't live). I've also set this up at <a href="http://jsbin.com/ifebe4" rel="noreferrer">JS Bin</a>.</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;link class="jsbin" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1/themes/base/jquery-ui.css" rel="stylesheet" type="text/css" /&gt; &lt;script class="jsbin" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"&gt;&lt;/script&gt; &lt;script class="jsbin" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.0/jquery-ui.min.js"&gt;&lt;/script&gt; &lt;link class="jsbin" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1/themes/base/jquery-ui.css" rel="stylesheet" type="text/css" /&gt; &lt;/head&gt; &lt;body&gt; &lt;button class="editMe" name="2810"&gt;edit&lt;/button&gt; &lt;button class="editMe" name="2811"&gt;edit&lt;/button&gt; &lt;button class="editMe" name="2812"&gt;edit&lt;/button&gt; &lt;button class="editMe" name="2813"&gt;edit&lt;/button&gt; &lt;div id="modify"&gt;&lt;/div&gt; &lt;/body&gt; &lt;/html&gt; ​ </code></pre> <p>​</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload