From dcaa358d1278449d9c081b2fd9eb7fdee3905ee4 Mon Sep 17 00:00:00 2001 From: Jimmy Brian Anamaria Torres Date: Thu, 20 Nov 2014 15:33:35 -0200 Subject: [PATCH] Validate is suggestions is undefined --- dist/jquery.autocomplete.js | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/dist/jquery.autocomplete.js b/dist/jquery.autocomplete.js index f89ecd3..5dd4edc 100644 --- a/dist/jquery.autocomplete.js +++ b/dist/jquery.autocomplete.js @@ -780,23 +780,29 @@ var that = this, options = that.options; - result.suggestions = that.verifySuggestionsFormat(result.suggestions); + // Validate if suggestions is undefined + if (result.suggestions !== undefined) { + result.suggestions = that.verifySuggestionsFormat(result.suggestions); - // Cache results if cache is not disabled: - if (!options.noCache) { - that.cachedResponse[cacheKey] = result; - if (options.preventBadQueries && result.suggestions.length === 0) { - that.badQueries.push(originalQuery); + // Cache results if cache is not disabled: + if (!options.noCache) { + that.cachedResponse[cacheKey] = result; + if (options.preventBadQueries && result.suggestions.length === 0) { + that.badQueries.push(originalQuery); + } } - } - // Return if originalQuery is not matching current query: - if (originalQuery !== that.getQuery(that.currentValue)) { + // Return if originalQuery is not matching current query: + if (originalQuery !== that.getQuery(that.currentValue)) { + return; + } + + + that.suggestions = result.suggestions; + that.suggest(); + } else { return; } - - that.suggestions = result.suggestions; - that.suggest(); }, activate: function (index) {