title: Alter the filter on autocomplete to allow sorting on complete string
body: <p>I have a functioning autocomplete jQuery input control but there are two things it is doing that I would like to alter.  </p>
  
  <p>First, it fires again and again.  I would like for the data to be returned once, cached and not called again.</p>
  
  <p>Second, I would like for the user to type in the control and based on what they type be able to search the entire string and not just the beginning.</p>
  
  <p>This is my functioning script that returns data to the autocomplete and WORKS.</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  
  $(function () {
      $('#datePicker').datepicker();
  });
  
  $(document).ready(function() {
  
      $("#autocomplete").autocomplete({
          source: function (request, response) {
              $.ajax({
                  url: "FacilitiesAsync",
                  type: 'GET',
                  cache: true,
                  data: 'sourceDb=myDb',
                  dataType: 'json',
                  success: function (json) {
                      // call autocomplete callback method with results 
                      response($.map(json, function (name) {
                          return {
                              label: name.label,
                              value: name.value
                          };
                      }));
                  },
                  error: function (xmlHttpRequest, textStatus, errorThrown) {
                      $("#autocomplete").text(textStatus + ', ' + errorThrown);
                  }
              });
          },
          select: function (event, ui) {
              $('#autocomplete').val(ui.item.label);
              return false;
          },
          messages: {
              noResults: '',
              results: function () {
              }
          }
      });
  });
  
  &lt;/script&gt;
  </code></pre>
  
  <p>I found this bit of code that overrides the filter feature of the autocomplete but I have NO IDEA where to add this.  I have tried several places to no avail....</p>
  
  <pre><code>// Overrides the default autocomplete filter function to search only from the beginning of the string
  $("#autocomplete").autocomplete.filter = function (array, term) {
      var matcher = new RegExp("\\b" + $.ui.autocomplete.escapeRegex(term), "i");
      return $.grep(array, function (value) {
      return matcher.test(value.label || value.value || value);
    });
  }; 
  </code></pre>
  
  <p>My input control looks like this.</p>
  
  <pre><code>&lt;input id="autocomplete" /&gt;      
  </code></pre>
  
  <p>I appreciate the direction...</p>