title: how to re-init JQuery autocomplete in a refreshed DIV?
body: <p>I have DIV, inside it an autocomplete widget copied form the JQuery samples: <a href="http://jqueryui.com/resources/demos/autocomplete/default.html" rel="nofollow">http://jqueryui.com/resources/demos/autocomplete/default.html</a> </p>
  
  <p>At button presses, the content of the DIV is replaced with new HTML, with the HEADER containing dynamically generated  Javascript to initialize the autocomplete</p>
  
  <pre><code>&lt;head&gt; .. 
  &lt;script&gt;
  $(function() {
      var availableTags = [
          "ActionScript",
          "AppleScript",
          "Scala",
          "Scheme"
      ];
      $( "#tags" ).autocomplete({
          source: availableTags
      });
  });
  </code></pre>
  
  <p>My problem is: the $(function()) is not evaluated at subequent reloads of the DIV == autocomplete does not work . </p>
  
  <p>Surprise surprise, there is no "ready" event for DIVs</p>
  
  <p>Please advise how to re-initialize the autocomplete code.</p>
  
  <p>The main page contains a PROJECT selector, on change will reload the DIV with dynamically generated details including an autocomplete widget.</p>
  
  <pre><code>&lt;html&gt;
   &lt;head&gt;
    &lt;script&gt;
     function refresh_div() {
      ..    
      document.getElementById(DYNA_DIV).innerHTML = self.xmlHttpReq.responseText;
     }
    &lt;/script&gt;
   &lt;/head&gt;
  &lt;body&gt;
   &lt;select id=PROJECT_ID onchange="refresh_div()" ..&gt;
   &lt;div id="DYNA_DIV"&gt; ..here is dynamically generated form with autocomplete widget containing items related to the PROJECT selected above&lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>The HTML for the DIV is bellow. Stripped off the HTML, HEAD, BODY as suggested</p>
  
  <p>At first load autocomplete works. When refreshing the content of the DIV, the initializer script bellow does not run</p>
  
  <pre><code>  ..  &lt;input type="text" name="AUTOCOMP"&gt; ..
  
   &lt;script&gt;
      $(function() {
          var availableItems = [ &lt;% dynamically enumerate items for PROECT_ID %&gt; ];
  
          $( "#AUTOCOMP" ).autocomplete({
              source: availableItems
          });
      });    
  
    &lt;/script&gt;
  </code></pre>
  
  <p>-alex</p>