|
179 | 179 | that.el.on('keydown.autocomplete', function (e) { that.onKeyPress(e); }); |
180 | 180 | that.el.on('keyup.autocomplete', function (e) { that.onKeyUp(e); }); |
181 | 181 | that.el.on('blur.autocomplete', function () { that.onBlur(); }); |
182 | | - that.el.on('focus.autocomplete', function () { that.fixPosition(); }); |
| 182 | + that.el.on('focus.autocomplete', function () { that.onFocus(); }); |
183 | 183 | that.el.on('change.autocomplete', function (e) { that.onKeyUp(e); }); |
184 | 184 | }, |
185 | 185 |
|
| 186 | + onFocus: function () { |
| 187 | + var that = this; |
| 188 | + that.fixPosition(); |
| 189 | + if (that.options.minChars <= that.el.val().length) { |
| 190 | + that.onValueChange(); |
| 191 | + } |
| 192 | + }, |
| 193 | + |
186 | 194 | onBlur: function () { |
187 | 195 | this.enableKillerFn(); |
188 | 196 | }, |
|
259 | 267 | that.intervalId = window.setInterval(function () { |
260 | 268 | that.hide(); |
261 | 269 | that.stopKillSuggestions(); |
262 | | - }, 300); |
| 270 | + }, 50); |
263 | 271 | }, |
264 | 272 |
|
265 | 273 | stopKillSuggestions: function () { |
|
430 | 438 | if ($.isFunction(options.serviceUrl)) { |
431 | 439 | serviceUrl = options.serviceUrl.call(that.element, q); |
432 | 440 | } |
433 | | - if(this.currentRequest != null) { |
434 | | - this.currentRequest.abort(); |
| 441 | + if (that.currentRequest) { |
| 442 | + that.currentRequest.abort(); |
435 | 443 | } |
436 | | - this.currentRequest = $.ajax({ |
| 444 | + that.currentRequest = $.ajax({ |
437 | 445 | url: serviceUrl, |
438 | 446 | data: options.ignoreParams ? null : options.params, |
439 | 447 | type: options.type, |
440 | 448 | dataType: options.dataType |
441 | 449 | }).done(function (data) { |
| 450 | + that.currentRequest = null; |
442 | 451 | that.processResponse(data, q); |
443 | 452 | options.onSearchComplete.call(that.element, q); |
444 | 453 | }); |
|
0 commit comments