Skip to content

Commit 0add15e

Browse files
author
Tomas Kirda
committed
Rev for 1.2.4 release
1 parent 3264901 commit 0add15e

File tree

3 files changed

+29
-27
lines changed

3 files changed

+29
-27
lines changed

dist/jquery.autocomplete.js

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Ajax Autocomplete for jQuery, version 1.2.3
2+
* Ajax Autocomplete for jQuery, version 1.2.4
33
* (c) 2013 Tomas Kirda
44
*
55
* Ajax Autocomplete for jQuery is freely distributable under the terms of an MIT-style license.
@@ -89,6 +89,7 @@
8989
onSearchComplete: noop,
9090
containerClass: 'autocomplete-suggestions',
9191
tabDisabled: false,
92+
dataType : 'text',
9293
lookupFilter: function (suggestion, originalQuery, queryLowerCase) {
9394
return suggestion.value.toLowerCase().indexOf(queryLowerCase) !== -1;
9495
},
@@ -179,7 +180,7 @@
179180

180181
// Listen for click event on suggestions list:
181182
container.on('click', suggestionSelector, function () {
182-
that.select($(this).data('index'));
183+
that.select($(this).data('index'), false);
183184
});
184185

185186
that.fixPosition();
@@ -243,7 +244,7 @@
243244
}
244245

245246
offset = that.el.offset();
246-
247+
247248
$(that.suggestionsContainer).css({
248249
top: (offset.top + that.el.outerHeight()) + 'px',
249250
left: offset.left + 'px'
@@ -297,7 +298,7 @@
297298
that.hide();
298299
return;
299300
}
300-
that.select(that.selectedIndex);
301+
that.select(that.selectedIndex, e.keyCode === keys.RETURN);
301302
if (e.keyCode === keys.TAB && this.options.tabDisabled === false) {
302303
return;
303304
}
@@ -359,7 +360,7 @@
359360
return;
360361
}
361362

362-
if (q === '' || q.length < that.options.minChars) {
363+
if (q.length < that.options.minChars) {
363364
that.hide();
364365
} else {
365366
that.getSuggestions(q);
@@ -406,7 +407,7 @@
406407
url: options.serviceUrl,
407408
data: options.params,
408409
type: options.type,
409-
dataType: 'text'
410+
dataType: options.dataType
410411
}).done(function (txt) {
411412
that.processResponse(txt);
412413
options.onSearchComplete.call(that.element, q);
@@ -476,7 +477,7 @@
476477

477478
processResponse: function (text) {
478479
var that = this,
479-
response = $.parseJSON(text);
480+
response = typeof text == 'string' ? $.parseJSON(text) : text;
480481

481482
response.suggestions = that.verifySuggestionsFormat(that.options.transformResult(response));
482483

@@ -515,13 +516,13 @@
515516
return null;
516517
},
517518

518-
select: function (i) {
519+
select: function (i, shouldIgnoreNextValueChange) {
519520
var that = this,
520521
selectedValue = that.suggestions[i];
521522

522523
if (selectedValue) {
523524
that.el.val(selectedValue);
524-
that.ignoreValueChange = true;
525+
that.ignoreValueChange = shouldIgnoreNextValueChange;
525526
that.hide();
526527
that.onSelect(i);
527528
}

dist/jquery.autocomplete.min.js

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

src/jquery.autocomplete.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Ajax Autocomplete for jQuery, version 1.2.3
2+
* Ajax Autocomplete for jQuery, version 1.2.4
33
* (c) 2013 Tomas Kirda
44
*
55
* Ajax Autocomplete for jQuery is freely distributable under the terms of an MIT-style license.

0 commit comments

Comments
 (0)