title: Auto Select Single Match jQuery UI Autocomplete Combobox
body: <p>I am using a slightly popular Combobox UI element which is a custom jQuery UI Autocomplete extension: <a href="http://jqueryui.com/autocomplete/#combobox" rel="nofollow">see here</a></p>
  
  <p>I would like, if there is a single match to select that match and also fire the selected event, specifically changing this section of code in the Autocomplete Combobox should be the solution:</p>
  
  <pre><code>    _source: function (request, response) {
                  var matcher = new RegExp($.ui.autocomplete.escapeRegex(request.term), "i");
                  response(this.element.children("option").map(function () {
                      var text = $(this).text();
                      var value = $(this).val();
                      if (this.value &amp;&amp; (!request.term || matcher.test(text)))
                          return {
                              label: text,
                              value: value,
                              option: this
                          };
                  }));
              }
  </code></pre>
  
  <p>I am not familiar with the jQuery map function, its syntax does not feel familiar to me even though I am very familiar with jQuery and vanilla Javascript, though I understand what the function is doing.</p>
  
  <p>I would like to something like:</p>
  
  <pre><code>if(match.count == 1)
     //fire select event and/or select option in hidden select list
  </code></pre>