2
0
mirror of https://github.com/devbridge/jQuery-Autocomplete.git synced 2024-11-25 22:27:39 +00:00

onSearchHasZeroRows and onSearchHasRows callback processing

This commit is contained in:
dima 2014-02-12 14:14:35 +04:00
parent 702bc0e9c3
commit c14d49d0fa

View File

@ -70,6 +70,8 @@
noCache: false, noCache: false,
onSearchStart: noop, onSearchStart: noop,
onSearchComplete: noop, onSearchComplete: noop,
onSearchHasZeroRows: noop,
onSearchHasRows: noop,
onSearchError: noop, onSearchError: noop,
containerClass: 'autocomplete-suggestions', containerClass: 'autocomplete-suggestions',
tabDisabled: false, tabDisabled: false,
@ -543,6 +545,8 @@
}, },
suggest: function () { suggest: function () {
this.beforeSuggest();
if (this.suggestions.length === 0) { if (this.suggestions.length === 0) {
this.hide(); this.hide();
return; return;
@ -632,6 +636,14 @@
(this.options.onHint || $.noop)(hintValue); (this.options.onHint || $.noop)(hintValue);
} }
}, },
beforeSuggest: function() {
if (this.suggestions.length === 0) {
this.options.onSearchHasZeroRows.call();
} else {
this.options.onSearchHasRows.call();
}
},
verifySuggestionsFormat: function (suggestions) { verifySuggestionsFormat: function (suggestions) {
// If suggestions is string array, convert them to supported format: // If suggestions is string array, convert them to supported format: