Fixed autocomplete staying even after hiding input

This commit is contained in:
Marcin Kurczewski 2014-11-30 13:05:31 +01:00
parent b70231bd7e
commit c0a5c800e0

View file

@ -24,6 +24,7 @@ App.Controls.AutoCompleteInput = function($input) {
var cachedSource = null;
var results = [];
var activeResult = -1;
var monitorInputHidingInterval = null;
if ($input.length === 0) {
throw new Error('Input element was not found');
@ -134,6 +135,7 @@ App.Controls.AutoCompleteInput = function($input) {
function hide() {
$div.hide();
window.clearInterval(monitorInputHidingInterval);
}
function selectPrevious() {
@ -232,6 +234,7 @@ App.Controls.AutoCompleteInput = function($input) {
top: ($input.offset().top + $input.outerHeight() - 2) + 'px',
});
$div.show();
monitorInputHiding();
}
function refreshActiveResult() {
@ -241,5 +244,13 @@ App.Controls.AutoCompleteInput = function($input) {
}
}
function monitorInputHiding() {
monitorInputHidingInterval = window.setInterval(function() {
if (!$input.is(':visible')) {
hide();
}
}, 100);
}
return options;
};