title: How to properly override jquery ui autocomplete?
body: <p>I am overriding the jquery ui method for close. In this way, I can have it close based on a <code>selected</code> variable I establish.</p>
  
  <pre><code>var originalCloseMethod = $input.data("autocomplete").close();
  $input.data("autocomplete").close = function(event) {
    if (!selected){
      originalCloseMethod.apply(this, arguments);
    }
    selected = false;
  };
  </code></pre>
  
  <p>It works great <em>except</em> for when it needs to make a regular closer. For example, if I click outside of the autocomplete div. The API then calls for close and returns this :</p>
  
  <blockquote>
    <p>originalCloseMethod is undefined</p>
  </blockquote>
  
  <p>Which makes me realize that it's calling this method internally inside the UI.</p>
  
  <p>This is why I am assuming that the best way to write this code, is to extend the UI not just override it.</p>
  
  <p>My question is, how would I apply this same method as an extension as opposed to an override?</p>