Loading a Page into a jQuery Dialog
<p>I tend to follow a fairly "modular" approach to building applications and I recently started working with jQuery.  The application I'm working on is going to be fairly large so I'm trying to break pieces out into separate files/modules when possible.  One example of this is a "User Settings" dialog.</p>

<p>This dialog has a form, a few tabs, and quite a good number of input fields so I want to develop it in a separate HTML file (PHP actually, but it can be considered HTML for the purposes of this example).  It's an entire page in and of itself with all the tags you would expect such as:</p>

<pre><code>&lt;html&gt;&lt;head&gt;&lt;/head&gt;&lt;body&gt;&lt;/body&gt;&lt;/html&gt;
</code></pre>

<p>So I can now develop, what I want to be, the dialog separate from the base application.  This dialog has it's own Javascript (A LOT of Javascript, in fact) in the head as well, with jQuery $(document).ready(){} capturing, etc.  Everything works flawlessly in isolation.  However, when I attempt to load the jQuery modal dialog with the page (inside of the main application page), as one might expect, trouble ensues.</p>

<p>Here's a brief, very simple, example of what it looks like:</p>

<pre><code>editUserDialog.load ("editUser.php", {id : $('#userList').val(), popup : "true"}, function     () {
  editUserDialog.dialog ("option", "title" , "Edit User");
  editUserDialog.dialog ('open');
});
</code></pre>

<p>(I'm passing in a "popup" flag to the page so that the page can determine its context -- i.e. as a page or inside of the jQuery dialog).</p>

<p><b>Question 1</b>:  When I moved the code from the "head" into "body" (in the editUser.php page) it actually worked for the most part.  It seemed that jQuery was calling the $(document).ready() function in the context of the body of the loaded file and not the head.  Is this a bad idea?</p>

<p><b>Question 2</b>:  Is my process for building this application just totally flawed to begin with?</p>

<p>I've scoured the net to attempt to find a "best practices" sort of document to building reasonably large applications using jQuery/PHP without a lot of success so maybe there's something out there someone else is aware of that I've somehow missed.</p>

<p>Thanks for bearing with me while I attempt to describe the issues I've encountered and I hope I've accurately described the problem.</p>
