From c14d49d0fa046bd6c64b76d472bb003e0c9b69d7 Mon Sep 17 00:00:00 2001 From: dima Date: Wed, 12 Feb 2014 14:14:35 +0400 Subject: [PATCH] onSearchHasZeroRows and onSearchHasRows callback processing --- src/jquery.autocomplete.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/jquery.autocomplete.js b/src/jquery.autocomplete.js index f2114bf..7315394 100644 --- a/src/jquery.autocomplete.js +++ b/src/jquery.autocomplete.js @@ -70,6 +70,8 @@ noCache: false, onSearchStart: noop, onSearchComplete: noop, + onSearchHasZeroRows: noop, + onSearchHasRows: noop, onSearchError: noop, containerClass: 'autocomplete-suggestions', tabDisabled: false, @@ -543,6 +545,8 @@ }, suggest: function () { + this.beforeSuggest(); + if (this.suggestions.length === 0) { this.hide(); return; @@ -632,6 +636,14 @@ (this.options.onHint || $.noop)(hintValue); } }, + + beforeSuggest: function() { + if (this.suggestions.length === 0) { + this.options.onSearchHasZeroRows.call(); + } else { + this.options.onSearchHasRows.call(); + } + }, verifySuggestionsFormat: function (suggestions) { // If suggestions is string array, convert them to supported format: