From 5d5513f0f2cdcf230cb491c7b756dd8ded53515c Mon Sep 17 00:00:00 2001 From: Steffen Dietz Date: Thu, 28 Aug 2014 12:14:36 +0200 Subject: [PATCH] added onHide callback option --- src/jquery.autocomplete.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/jquery.autocomplete.js b/src/jquery.autocomplete.js index 1bc99cd..e3ae7fd 100644 --- a/src/jquery.autocomplete.js +++ b/src/jquery.autocomplete.js @@ -593,7 +593,14 @@ }, hide: function () { - var that = this; + var that = this, + container = $(that.suggestionsContainer); + + if ($.isFunction(this.options.onHide) && that.visible) { + + this.options.onHide.call(that.element, container); + } + that.visible = false; that.selectedIndex = -1; $(that.suggestionsContainer).hide(); @@ -602,7 +609,7 @@ suggest: function () { if (this.suggestions.length === 0) { - this.options.showNoSuggestionNotice ? this.noSuggestions() : this.hide(); + this.options.showNoSuggestionNotice ? this.noSuggestions() : this.hide(); return; } @@ -631,7 +638,7 @@ html += '
' + formatResult(suggestion, value) + '
'; }); - this.adjustContainerWidth(); + this.adjustContainerWidth(); noSuggestionsContainer.detach(); container.html(html);