2
0
mirror of https://github.com/devbridge/jQuery-Autocomplete.git synced 2024-09-19 08:49:01 +00:00

Updated onHint

This commit is contained in:
geoffrosen 2021-01-24 14:12:47 -06:00 committed by GitHub
parent 75fd1b391d
commit a4d35398cc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -95,6 +95,7 @@
serviceUrl: null, serviceUrl: null,
lookup: null, lookup: null,
onSelect: null, onSelect: null,
onHint: null,
width: 'auto', width: 'auto',
minChars: 1, minChars: 1,
maxHeight: 300, maxHeight: 300,
@ -632,7 +633,7 @@
that.selectedIndex = -1; that.selectedIndex = -1;
clearTimeout(that.onChangeTimeout); clearTimeout(that.onChangeTimeout);
$(that.suggestionsContainer).hide(); $(that.suggestionsContainer).hide();
that.signalHint(null); that.onHint(null);
}, },
suggest: function () { suggest: function () {
@ -768,20 +769,24 @@
return !foundMatch; return !foundMatch;
}); });
that.signalHint(bestMatch); that.onHint(bestMatch);
}, },
signalHint: function (suggestion) { onHint: function (suggestion) {
var hintValue = '', var that = this,
that = this; onHintCallback = that.options.onHint,
hintValue = '';
if (suggestion) { if (suggestion) {
hintValue = that.currentValue + suggestion.value.substr(that.currentValue.length); hintValue = that.currentValue + suggestion.value.substr(that.currentValue.length);
} }
if (that.hintValue !== hintValue) { if (that.hintValue !== hintValue) {
that.hintValue = hintValue; that.hintValue = hintValue;
that.hint = suggestion; that.hint = suggestion;
(this.options.onHint || $.noop)(hintValue); if ($.isFunction(onHintCallback)) {
} onHintCallback.call(that.element, hintValue);
}
}
}, },
verifySuggestionsFormat: function (suggestions) { verifySuggestionsFormat: function (suggestions) {
@ -922,7 +927,7 @@
that.el.val(that.getValue(that.suggestions[index].value)); that.el.val(that.getValue(that.suggestions[index].value));
} }
that.signalHint(null); that.onHint(null);
}, },
onSelect: function (index) { onSelect: function (index) {
@ -936,7 +941,7 @@
that.el.val(that.currentValue); that.el.val(that.currentValue);
} }
that.signalHint(null); that.onHint(null);
that.suggestions = []; that.suggestions = [];
that.selection = suggestion; that.selection = suggestion;