code: function (e) {
          var that = this;
  
          // prevent moving focus out of the text field
          e.preventDefault();
  
          // IE doesn't prevent moving focus even with e.preventDefault()
          // so we set a flag to know when we should ignore the blur event
          that.cancelBlur = true;
          utils.delay(function () {
              delete that.cancelBlur;
          });
  
          // clicking on the scrollbar causes focus to shift to the body
          // but we can't detect a mouseup or a click immediately afterward
          // so we have to track the next mousedown and close the menu if
          // the user clicks somewhere outside of the autocomplete
          if ($(e.target).closest(".ui-menu-item").length == 0) {
              utils.delay(function () {
                  $(document).one("mousedown", function (e) {
                      var $elements = that.el
                          .add(that.$wrapper)
                          .add(that.options.$helpers);
  
                      if (that.options.floating) {
                          $elements = $elements.add(that.$container);
                      }
  
                      $elements = $elements.filter(function () {
                          return this === e.target || $.contains(this, e.target);
                      });
  
                      if (!$elements.length) {
                          that.hide();
                      }
                  });
              });
          }
      }
docs: This whole handler is needed to prevent blur event on textbox
  when suggestion is clicked (blur leads to suggestions hide, so we need to prevent it).
  See https://github.com/jquery/jquery-ui/blob/master/ui/autocomplete.js for details