title: How to use jQuery.autocomplete on a hidden input field (type="text")?
body: <p>I am trying to use the autocomplete from jQuery on an text field inside a hidden div. It doesn't seem to work, though the input field gains the ui-autocomplete-input class. It's like no event is bound to my input. </p>
  
  <p>Just to be clear, the code looks like this:</p>
  
  <pre><code>&lt;a href="#overlay" class="open-the-overlay-that-has-the-id-like-this-href-attribute"&gt;OPEN&lt;/a&gt;
  
  &lt;div id="overlay" style="display:none"&gt;
      &lt;form action="/action" method="post"&gt;
          &lt;input type="text" id="my-unique-id" /&gt;
          &lt;input type="submit" /&gt;
      &lt;/form&gt;
  &lt;/div&gt;
  
  &lt;script type="text/javascript"&gt;
  $(document).ready(function(){
  
      $("#my-unique-id").autocomplete({
          source: "search.php",
          minLength: 2
      });
  
  });
  &lt;/script&gt;
  </code></pre>
  
  <p>After this, the #my-unique-id gains the ui-autocomplete-input class but has no events bound.
  Any ideas?</p>
  
  <p>Here is the server side script, but it's nothing wrong with it, because on another field it works fine:</p>
  
  <p>(CakePHP)</p>
  
  <pre><code>function getCity() {
  
      $this-&gt;layout = FALSE;
      $this-&gt;autoRender = FALSE;
      Configure::write("debug",0);
  
      if(isset($_GET["term"]) &amp;&amp; !empty($_GET["term"])) {
          AppModel::unbind($this-&gt;City);
          preg_match_all("/(\w+)/",urldecode($_GET["term"]), $term);
          $or = array();
          foreach ($term[0] as $t) {
              if(strtolower($t) != "jud")
              $or[] = "City.name LIKE '%$t%'"; // OR City.county LIKE '%$t%'
          }
          $or = implode(" OR ", $or);
          $cities = $this-&gt;City-&gt;find("all", array("limit"=&gt;30, "fields"=&gt;array("City.id", "City.name", "City.county"),"conditions"=&gt;array($or)));
          $returnArray = array();
          $k = 0;
          foreach($cities as $c) {
              $returnArray[$k]['id'] = $c["City"]["id"];
              $returnArray[$k]['label'] = $c["City"]["name"].", jud. ".$c["City"]["county"];
              $returnArray[$k]['value'] = $c["City"]["name"].", jud. ".$c["City"]["county"];
              $k++;
          }
          return json_encode($returnArray);
      }
  }
  </code></pre>