mirror of
https://github.com/devbridge/jQuery-Autocomplete.git
synced 2024-11-25 06:07:45 +00:00
Enable support for minChars: 0. Fixes #95.
This commit is contained in:
parent
2f260cec63
commit
1906d93ff9
@ -56,6 +56,7 @@ $(function () {
|
||||
// Initialize autocomplete with local lookup:
|
||||
$('#autocomplete').autocomplete({
|
||||
lookup: countriesArray,
|
||||
minChars: 0,
|
||||
onSelect: function (suggestion) {
|
||||
$('#selection').html('You selected: ' + suggestion.value + ', ' + suggestion.data);
|
||||
}
|
||||
|
@ -179,10 +179,18 @@
|
||||
that.el.on('keydown.autocomplete', function (e) { that.onKeyPress(e); });
|
||||
that.el.on('keyup.autocomplete', function (e) { that.onKeyUp(e); });
|
||||
that.el.on('blur.autocomplete', function () { that.onBlur(); });
|
||||
that.el.on('focus.autocomplete', function () { that.fixPosition(); });
|
||||
that.el.on('focus.autocomplete', function () { that.onFocus(); });
|
||||
that.el.on('change.autocomplete', function (e) { that.onKeyUp(e); });
|
||||
},
|
||||
|
||||
onFocus: function () {
|
||||
var that = this;
|
||||
that.fixPosition();
|
||||
if (that.options.minChars <= that.el.val().length) {
|
||||
that.onValueChange();
|
||||
}
|
||||
},
|
||||
|
||||
onBlur: function () {
|
||||
this.enableKillerFn();
|
||||
},
|
||||
@ -259,7 +267,7 @@
|
||||
that.intervalId = window.setInterval(function () {
|
||||
that.hide();
|
||||
that.stopKillSuggestions();
|
||||
}, 300);
|
||||
}, 50);
|
||||
},
|
||||
|
||||
stopKillSuggestions: function () {
|
||||
@ -430,15 +438,16 @@
|
||||
if ($.isFunction(options.serviceUrl)) {
|
||||
serviceUrl = options.serviceUrl.call(that.element, q);
|
||||
}
|
||||
if(this.currentRequest != null) {
|
||||
this.currentRequest.abort();
|
||||
if (that.currentRequest) {
|
||||
that.currentRequest.abort();
|
||||
}
|
||||
this.currentRequest = $.ajax({
|
||||
that.currentRequest = $.ajax({
|
||||
url: serviceUrl,
|
||||
data: options.ignoreParams ? null : options.params,
|
||||
type: options.type,
|
||||
dataType: options.dataType
|
||||
}).done(function (data) {
|
||||
that.currentRequest = null;
|
||||
that.processResponse(data, q);
|
||||
options.onSearchComplete.call(that.element, q);
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user