From 7f3eea32632d2d5777c8617a0f864fc2671fc658 Mon Sep 17 00:00:00 2001 From: Raf Philtjens Date: Tue, 9 Sep 2014 17:00:20 +0200 Subject: [PATCH] added onScroll callback --- src/jquery.autocomplete.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/jquery.autocomplete.js b/src/jquery.autocomplete.js index 91fa30d..b5f088f 100644 --- a/src/jquery.autocomplete.js +++ b/src/jquery.autocomplete.js @@ -61,6 +61,7 @@ serviceUrl: null, lookup: null, onSelect: null, + onScroll: null, width: 'auto', minChars: 1, maxHeight: 300, @@ -832,7 +833,9 @@ offsetTop, upperBound, lowerBound, - heightDelta = 25; + heightDelta = 25, + onScrollCallback = that.options.onScroll, + suggestion = that.suggestions[index]; if (!activeItem) { return; @@ -848,8 +851,12 @@ $(that.suggestionsContainer).scrollTop(offsetTop - that.options.maxHeight + heightDelta); } - that.el.val(that.getValue(that.suggestions[index].value)); + that.el.val(that.getValue(suggestion.value)); that.signalHint(null); + + if ($.isFunction(onScrollCallback)) { + onScrollCallback.call(that.element, suggestion); + } }, onSelect: function (index) {