title: How to get the index of a selected item in autocomplete?
body: <p>I'm using the autocomplete feature of jQueryUI. It correctly gives list the items and I'm able to make a selection from the list. The problem I'm having is how to get the index of the selected item which is from an array used in the source event.</p>
  
  <pre><code>var options = {
      select: function() {
          // problem is here, I'm not able to see the correct index number of the selected item and always say -1
          alert($.inArray($("#searchAText").val()), arrayA); 
      },
      source: function(req, response) {
          var re = $.ui.autocomplete.escapeRegex(reg, term);
          var matcher = new RegExp("^" + re + "i");
          response($.grep(arrayA, function(item, index) {
              return matcher.test(item);
          })); 
      }
  };
  }
  </code></pre>