Skip to content

Commit 612838a

Browse files
committed
Autocomplete: Added position option. Fixes #5153 - Autocomplete position option.
1 parent 5435c50 commit 612838a

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

tests/unit/autocomplete/autocomplete_defaults.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,12 @@ var autocomplete_defaults = {
66
delay: 300,
77
disabled: false,
88
minLength: 1,
9-
source: undefined
9+
position: {
10+
my: "left top",
11+
at: "left bottom",
12+
collision: "none"
13+
},
14+
source: null
1015
};
1116

1217
commonWidgetTests('autocomplete', { defaults: autocomplete_defaults });

ui/jquery.ui.autocomplete.js

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,14 @@
1616

1717
$.widget( "ui.autocomplete", {
1818
options: {
19+
delay: 300,
1920
minLength: 1,
20-
delay: 300
21+
position: {
22+
my: "left top",
23+
at: "left bottom",
24+
collision: "none"
25+
},
26+
source: null
2127
},
2228
_create: function() {
2329
var self = this,
@@ -269,12 +275,9 @@ $.widget( "ui.autocomplete", {
269275
// TODO refresh should check if the active item is still in the dom, removing the need for a manual deactivate
270276
this.menu.deactivate();
271277
this.menu.refresh();
272-
this.menu.element.show().position({
273-
my: "left top",
274-
at: "left bottom",
275-
of: this.element,
276-
collision: "none"
277-
});
278+
this.menu.element.show().position( $.extend({
279+
of: this.element
280+
}, this.options.position ));
278281

279282
menuWidth = ul.width( "" ).outerWidth();
280283
textWidth = this.element.outerWidth();

0 commit comments

Comments
 (0)