Skip to content

Commit ee58414

Browse files
author
Tomas Kirda
committed
Update suggestions position on window resize.
1 parent 074c44e commit ee58414

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/jquery.autocomplete.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@
142142
container = $(that.suggestionsContainer);
143143

144144
container.appendTo(options.appendTo);
145-
145+
146146
// Only set width if it was provided:
147147
if (options.width !== 'auto') {
148148
container.width(options.width);
@@ -166,6 +166,12 @@
166166

167167
that.fixPosition();
168168

169+
that.fixPositionCapture = function () {
170+
that.fixPosition();
171+
};
172+
173+
$(window).on('resize', that.fixPositionCapture);
174+
169175
that.el.on('keydown.autocomplete', function (e) { that.onKeyPress(e); });
170176
that.el.on('keyup.autocomplete', function (e) { that.onKeyUp(e); });
171177
that.el.on('blur.autocomplete', function () { that.onBlur(); });
@@ -219,8 +225,8 @@
219225
var that = this,
220226
offset;
221227

222-
// Don't adjsut position if custom container has been specified:
223-
if (that.options.appendTo !== 'body') {
228+
// Don't adjsut position if not visible or custom container has been specified:
229+
if (!that.visible || that.options.appendTo !== 'body') {
224230
return;
225231
}
226232

@@ -605,6 +611,7 @@
605611
var that = this;
606612
that.el.off('.autocomplete').removeData('autocomplete');
607613
that.disableKillerFn();
614+
$(window).off('resize', that.fixPositionCapture);
608615
$(that.suggestionsContainer).remove();
609616
}
610617
};

0 commit comments

Comments
 (0)