Skip to content

Commit 364fd6a

Browse files
author
Tomas Kirda
committed
Rev for 1.2.5 release
1 parent 7af8d62 commit 364fd6a

File tree

5 files changed

+41
-46
lines changed

5 files changed

+41
-46
lines changed

devbridge-autocomplete.jquery.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"ajax",
77
"autocomplete"
88
],
9-
"version": "1.2.3",
9+
"version": "1.2.5",
1010
"author": {
1111
"name": "Tomas Kirda",
1212
"url": "https://github.com/tkirda"

dist/jquery.autocomplete.js

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Ajax Autocomplete for jQuery, version 1.2.4
2+
* Ajax Autocomplete for jQuery, version 1.2.5
33
* (c) 2013 Tomas Kirda
44
*
55
* Ajax Autocomplete for jQuery is freely distributable under the terms of an MIT-style license.
@@ -89,13 +89,13 @@
8989
onSearchComplete: noop,
9090
containerClass: 'autocomplete-suggestions',
9191
tabDisabled: false,
92-
dataType : 'text',
92+
dataType: 'text',
9393
lookupFilter: function (suggestion, originalQuery, queryLowerCase) {
9494
return suggestion.value.toLowerCase().indexOf(queryLowerCase) !== -1;
9595
},
9696
paramName: 'query',
9797
transformResult: function (response) {
98-
return response.suggestions;
98+
return typeof response === 'string' ? $.parseJSON(response) : response;
9999
}
100100
};
101101

@@ -244,7 +244,7 @@
244244
}
245245

246246
offset = that.el.offset();
247-
247+
248248
$(that.suggestionsContainer).css({
249249
top: (offset.top + that.el.outerHeight()) + 'px',
250250
left: offset.left + 'px'
@@ -401,15 +401,15 @@
401401
that.suggestions = response.suggestions;
402402
that.suggest();
403403
} else if (!that.isBadQuery(q)) {
404-
options.onSearchStart.call(that.element, q);
405404
options.params[options.paramName] = q;
405+
options.onSearchStart.call(that.element, options.params);
406406
$.ajax({
407407
url: options.serviceUrl,
408408
data: options.params,
409409
type: options.type,
410410
dataType: options.dataType
411-
}).done(function (txt) {
412-
that.processResponse(txt);
411+
}).done(function (data) {
412+
that.processResponse(data, q);
413413
options.onSearchComplete.call(that.element, q);
414414
});
415415
}
@@ -475,23 +475,24 @@
475475
return suggestions;
476476
},
477477

478-
processResponse: function (text) {
478+
processResponse: function (response, originalQuery) {
479479
var that = this,
480-
response = typeof text == 'string' ? $.parseJSON(text) : text;
480+
options = that.options,
481+
result = options.transformResult(response, originalQuery);
481482

482-
response.suggestions = that.verifySuggestionsFormat(that.options.transformResult(response));
483+
result.suggestions = that.verifySuggestionsFormat(result.suggestions);
483484

484485
// Cache results if cache is not disabled:
485-
if (!that.options.noCache) {
486-
that.cachedResponse[response[that.options.paramName]] = response;
487-
if (response.suggestions.length === 0) {
488-
that.badQueries.push(response[that.options.paramName]);
486+
if (!options.noCache) {
487+
that.cachedResponse[result[options.paramName]] = result;
488+
if (result.suggestions.length === 0) {
489+
that.badQueries.push(result[options.paramName]);
489490
}
490491
}
491492

492493
// Display suggestions only if returned query matches current value:
493-
if (response[that.options.paramName] === that.getQuery(that.currentValue)) {
494-
that.suggestions = response.suggestions;
494+
if (originalQuery === that.getQuery(that.currentValue)) {
495+
that.suggestions = result.suggestions;
495496
that.suggest();
496497
}
497498
},
@@ -631,4 +632,4 @@
631632
}
632633
});
633634
};
634-
}));
635+
}));

dist/jquery.autocomplete.min.js

Lines changed: 15 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)