jQuery UI Dialog - rearraning DOM

jQuery UI Dialog - rearraning DOM

I noticed that when calling .dialog() it moves the html elements to the very end of the document.
This is a problem for me because I want my forms submit button in the dialog (while other form elements are not) - however, because it re-arranges the HTML, my submit button is no longer within my form tag - so the submit button does not work. Is there a way to prevent dialog() from re-arranging the DOM?

Example:

JS
$('#saveDialog').dialog();

HTML
<form method="post" action="/whatever">
<input type="text" name="name"/>
<div id="saveDialog">
<input type="submit" value="Save">
</div>
</form>

calling the .dialog() puts the div and my submit button outside the form. :(