2
0
mirror of https://github.com/devbridge/jQuery-Autocomplete.git synced 2024-11-22 04:45:12 +00:00

Introduce 'flex' width setting to auto size suggestion length

This commit is contained in:
Sam Hermans 2017-01-20 17:22:37 +01:00
parent 062811cd42
commit cfafe7ad6a
2 changed files with 6 additions and 1 deletions

View File

@ -52,7 +52,7 @@ The standard jquery.autocomplete.js file is around 13KB when minified.
format suggestion entry inside suggestions container, optional.
* `groupBy`: property name of the suggestion `data` object, by which results should be grouped.
* `maxHeight`: Maximum height of the suggestions container in pixels. Default: `300`.
* `width`: Suggestions container width in pixels, e.g.: 300. Default: `auto`, takes input field width.
* `width`: Suggestions container width in pixels, e.g.: 300, `flex` for max suggestion size and `auto` takes input field width. Default: `auto`
* `zIndex`: 'z-index' for suggestions container. Default: `9999`.
* `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.
* `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.

View File

@ -742,7 +742,12 @@
if (options.width === 'auto') {
width = that.el.outerWidth();
container.css('width', width > 0 ? width : 300);
} else if(options.width === 'flex') {
// Trust the source! Unset the width property so it will be the max lenght
// the containing elements.
container.css('width', '');
}
},
findBestHint: function () {