From b34fc5d9c7445abb36918a5eda05770fe21201e8 Mon Sep 17 00:00:00 2001 From: dima Date: Fri, 3 Oct 2014 15:08:59 +0400 Subject: [PATCH 1/2] fix for scroll on autoselect first item --- src/jquery.autocomplete.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/jquery.autocomplete.js b/src/jquery.autocomplete.js index c4864db..42725c3 100644 --- a/src/jquery.autocomplete.js +++ b/src/jquery.autocomplete.js @@ -661,6 +661,7 @@ // Select first value by default: if (options.autoSelectFirst) { that.selectedIndex = 0; + container.scrollTop(0); container.children().first().addClass(classSelected); } From 3048f48d1bca5f0537f2c693513d09f65737d8d1 Mon Sep 17 00:00:00 2001 From: dima Date: Fri, 3 Oct 2014 15:48:41 +0400 Subject: [PATCH 2/2] always work only after the show() method --- src/jquery.autocomplete.js | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/jquery.autocomplete.js b/src/jquery.autocomplete.js index 42725c3..f28bfae 100644 --- a/src/jquery.autocomplete.js +++ b/src/jquery.autocomplete.js @@ -658,6 +658,13 @@ noSuggestionsContainer.detach(); container.html(html); + if ($.isFunction(beforeRender)) { + beforeRender.call(that.element, container); + } + + that.fixPosition(); + container.show(); + // Select first value by default: if (options.autoSelectFirst) { that.selectedIndex = 0; @@ -665,15 +672,7 @@ container.children().first().addClass(classSelected); } - if ($.isFunction(beforeRender)) { - beforeRender.call(that.element, container); - } - - that.fixPosition(); - - container.show(); that.visible = true; - that.findBestHint(); },