Skip to content

Commit 6b83874

Browse files
author
Tomas Kirda
authored
Merge pull request #569 from MrSam/master
Introduce 'flex' width setting to auto size suggestion length
2 parents 062811c + eb7be99 commit 6b83874

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ The standard jquery.autocomplete.js file is around 13KB when minified.
5252
format suggestion entry inside suggestions container, optional.
5353
* `groupBy`: property name of the suggestion `data` object, by which results should be grouped.
5454
* `maxHeight`: Maximum height of the suggestions container in pixels. Default: `300`.
55-
* `width`: Suggestions container width in pixels, e.g.: 300. Default: `auto`, takes input field width.
55+
* `width`: Suggestions container width in pixels, e.g.: 300, `flex` for max suggestion size and `auto` takes input field width. Default: `auto`
5656
* `zIndex`: 'z-index' for suggestions container. Default: `9999`.
5757
* `appendTo`: container where suggestions will be appended. Default value `document.body`. Can be jQuery object, selector or HTML element. Make sure to set `position: absolute` or `position: relative` for that element.
5858
* `forceFixPosition`: Default: `false`. Suggestions are automatically positioned when their container is appended to body (look at `appendTo` option), in other cases suggestions are rendered but no positioning is applied.

src/jquery.autocomplete.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -742,6 +742,10 @@
742742
if (options.width === 'auto') {
743743
width = that.el.outerWidth();
744744
container.css('width', width > 0 ? width : 300);
745+
} else if(options.width === 'flex') {
746+
// Trust the source! Unset the width property so it will be the max length
747+
// the containing elements.
748+
container.css('width', '');
745749
}
746750
},
747751

0 commit comments

Comments
 (0)