title: JqueryUI : close autocomplete widget when last match lost
body: <p>I'm struggling with an issue on JqueryUI and its autocomplete widget. Whenever it finds at least one match, the widget appears fine. The issue occurs if the user doesn't select one of the proposals and keeps typing. Here is an example:</p>
  
  <p><img src="https://i.stack.imgur.com/LZeqX.png" alt="">  </p>
  
  <p>Auto complete finds matches, everything is fine.</p>
  
  <p><img src="https://i.stack.imgur.com/wVXJz.png" alt=""></p>
  
  <p>User keeps typing, the searchs results are narrowed, everything is still OK</p>
  
  <p><img src="https://i.stack.imgur.com/htUes.png" alt=""></p>
  
  <p>User keeps typing even more, there is no match left, but the widget remains open.</p>
  
  <p>This is the behaviour I want to get rid of. I'm running JqueryUi version 1.9.2. I read <a href="https://stackoverflow.com/questions/4718968/detecting-no-results-on-jquery-ui-autocomplete">this question</a> and tried using the widget's "response" event, as suggested.</p>
  
  <pre><code>response: function(event, ui) {
      if (ui.content.length === 0) {
          $("#field").autocomplete('close');
      }
  }
  </code></pre>
  
  <p>Unfortunately, this accomplishes nothing in my case, because there is no response event triggered when the last match is lost.</p>
  
  <p>Is there a way to fix this ? </p>
  
  <p>EDIT : It seems that later versions of jQuery UI fix this. Unfortunately, upgrading to versions 1.10+ implies a LOT of changes, and this library is used like everywhere in my project. That sounds like an extremly huge time investment to fix a minor annoyance. What I'm looking for is a easier workaround.</p>