Closed elektronika-ba closed 5 years ago
onBlur: function () {
var that = this,
options = that.options,
value = that.el.val(),
query = that.getQuery(value);
// If user clicked on a suggestion, hide() will
// be canceled, otherwise close suggestions
that.blurTimeoutId = setTimeout(function () {
that.hide();
// if selection is null auto pick a exact one is better
if (that.selection == null) {
var is_matched = false;
for (var index in that.suggestions) {
var itVal = that.getValue(that.suggestions[index].value);
if (itVal == query) {
that.onSelect(index);
is_matched = true;
break;
}
}
if (!is_matched) {
(options.onInvalidateSelection || $.noop).call(that.element);
}
} else if (that.selection && that.currentValue !== query) {
(options.onInvalidateSelection || $.noop).call(that.element);
}
}, 200);
},
Calling of
options.onInvalidateSelection
in onBlur timer if value has been changed.