title: JQuery UI AutoComplete: .data(...) is undefined [but only when I am add a second autocomplete box]
body: <p>I am using JQuery 1.8.3 and JQuery UI 1.8.24.</p>
  
  <p>This is the code, that works just fine:</p>
  
  <pre><code>
  
      $(function () {
          $("#").autocomplete({
              source: function (request, response) {
                  $.ajax({
                      url: '', type: "POST", dataType: "json",
                      data: { searchPattern: request.term },
                      cache: false,
                      success: function (data) {
                          response($.map(data, function (item) {
                              return { label: item.Label, value: item.Value, id: item.Id, description: item.Description }
                          }))
                      }
                  });
              },
              delay: 300,
              minLength: 2,
              autoFocus: true
          })
          .data("autocomplete")._renderItem = function (ul, item) {
              return $("li>/li>")
              .data("ui-autocomplete-item", item)
              .append("a>" + item.label + "br>div style=\"font-size:x-small;font-style:italic;\">" + item.description + "/div>/a>")
              .appendTo(ul);
          };
      });
  
  </code></pre>
  
  <p>But if I add a second textbox to the HTML, copy the JavaScript above and change the selector and url (so in the end I have two autocomplete textboxes), then I get the following error for the second autocomplete:</p>
  
  <pre><code>TypeError: $(...).autocomplete(...).data(...) is undefined
  </code></pre>
  
  <p>With one autocomplete it works perfect, but with a second not
  I can't explain why. Does anyone can help me?</p>
  
  <p>Thanks in advance!</p>
  
  <p>Toby</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>I found the problem.</p>
  
  <p>The JavaScript code is in an *.js file and the two textboxes are in two different *.thml files.</p>
  
  <p>So there is only one textbox at a time and this is the problem.</p>
  
  <p>Now I do the last part (with the data(...)) in the *.html file and it works fine:</p>
  
  <pre><code>$("#selector").autocomplete().data("autocomplete")._renderItem = renderItem;
  </code></pre>
  
  <p>Thank for your help!</p>