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

we're caching the lookup fn to avoid multiple wrapping

This commit is contained in:
Umur Kontacı 2013-08-17 11:51:53 +03:00
parent 6ef64da188
commit e0571afa17

View File

@ -102,6 +102,7 @@
that.hint = null;
that.hintValue = '';
that.selection = null;
that.cachedLookupFn = null;
// Initialize and set options:
that.initialize();
@ -197,11 +198,12 @@
that.isLocal = $.isArray(options.lookup) || $.isFunction(options.lookup);
if (that.isLocal) {
if ($.isFunction(options.lookup)) {
if ($.isFunction(options.lookup) && options.lookup !== that.cachedLookupFn) {
oldFn = options.lookup;
options.lookup = function () {
return that.verifySuggestionsFormat(oldFn.apply(that, arguments));
return that.verifySuggestionsFormat(oldFn.apply(that, arguments));
};
that.cachedLookupFn = options.lookup;
} else {
options.lookup = that.verifySuggestionsFormat(options.lookup);
}