Restore code for showing asyc the autocomplete.

This commit is contained in:
Israel Garcia 2017-06-19 12:39:15 -04:00
parent 4036f5cd28
commit f71aa6c5b9
1 changed files with 16 additions and 13 deletions

View File

@ -1115,20 +1115,23 @@ treemode._onKeyDown = function (event) {
(this.options.autocomplete.applyTo.indexOf('field') >= 0 && jsonElementType == "field")) {
var node = Node.getNodeFromTarget(event.target);
// Activate autocomplete
if (event.target.innerText.length > 0) {
var result = this.options.autocomplete.getOptions(this.autocomplete, node, event.target.innerText, jsonElementType);
setTimeout(function (hnode, element) {
if (element.innerText.length > 0) {
var result = this.options.autocomplete.getOptions(this.autocomplete, hnode, element.innerText, jsonElementType);
if (typeof result.then === 'function') {
// probably a promise
if (result.then(function (options) {
this.autocomplete.show(event.target, options);
this.autocomplete.show(element, options);
}.bind(this)));
} else {
// definitely not a promise
this.autocomplete.show(event.target, result);
this.autocomplete.show(element, result);
}
}
else
this.autocomplete.hideDropDown();
}.bind(this, node, event.target), 50);
}
}
}