2
0
mirror of https://github.com/devbridge/jQuery-Autocomplete.git synced 2024-11-30 00:33:55 +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.hint = null;
that.hintValue = ''; that.hintValue = '';
that.selection = null; that.selection = null;
that.cachedLookupFn = null;
// Initialize and set options: // Initialize and set options:
that.initialize(); that.initialize();
@ -197,11 +198,12 @@
that.isLocal = $.isArray(options.lookup) || $.isFunction(options.lookup); that.isLocal = $.isArray(options.lookup) || $.isFunction(options.lookup);
if (that.isLocal) { if (that.isLocal) {
if ($.isFunction(options.lookup)) { if ($.isFunction(options.lookup) && options.lookup !== that.cachedLookupFn) {
oldFn = options.lookup; oldFn = options.lookup;
options.lookup = function () { options.lookup = function () {
return that.verifySuggestionsFormat(oldFn.apply(that, arguments)); return that.verifySuggestionsFormat(oldFn.apply(that, arguments));
}; };
that.cachedLookupFn = options.lookup;
} else { } else {
options.lookup = that.verifySuggestionsFormat(options.lookup); options.lookup = that.verifySuggestionsFormat(options.lookup);
} }