title: jquery ui dialog call won't open from external file
body: <p>I have a UI Dialog for View selection that is on almost every page, so I moved it to an external js file. </p>
  
  <p>It works perfectly on every page where it is called by click functions, but on one page, where I am trying to automatically open dialog depending on the value of a javascript variable, it fails.</p>
  
  <p>Is this because when the external js file is loaded, the html of the dialog doesn't exist? If I move the in the external back to the page, it works Ok.</p>
  
  <p>Can anyone offer me a solution, I really would like to keep the View Dialog initialization code in the external files.</p>
  
  <p>External js file </p>
  
  <pre><code>$(function() { // ******* The Views Dialog
    var $divViewDialog = $('#divViewDialog');
    $divViewDialog.dialog({ autoOpen: false, modal: true,title: 'Select required view'});
    ..... etc
  </code></pre>
  
  <p>Page code calling the dialog -</p>
  
  <pre><code>$(function() {
  
  // ********* Other unrelated stuff
  
    if (ulx&gt;1) { $divViewDialog.dialog('open');} // If logged in, Show View Dialog
  
    else {$divLoginDialog.dialog('open');}       // else show Login Dialog
  </code></pre>
  
  <p>});</p>