2
0
mirror of https://github.com/devbridge/jQuery-Autocomplete.git synced 2024-12-22 19:08:55 +00:00

Allow to override formatGroup callback via options, closes #505, #387

This commit is contained in:
Tomas Kirda 2017-01-20 11:59:10 -06:00
parent 19a97900ec
commit f756a441bf
2 changed files with 8 additions and 1 deletions

View File

@ -50,6 +50,8 @@ The standard jquery.autocomplete.js file is around 13KB when minified.
* `beforeRender`: `function (container, suggestions) {}` called before displaying the suggestions. You may manipulate suggestions DOM before it is displayed.
* `formatResult`: `function (suggestion, currentValue) {}` custom function to
format suggestion entry inside suggestions container, optional.
* `formatGroup`: `function (suggestion, category) {}` custom function to
format group header, 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, `flex` for max suggestion size and `auto` takes input field width. Default: `auto`

View File

@ -67,6 +67,7 @@
deferRequestBy: 0,
params: {},
formatResult: Autocomplete.formatResult,
formatGroup: Autocomplete.formatGroup,
delimiter: null,
zIndex: 9999,
type: 'GET',
@ -143,6 +144,10 @@
.replace(/&lt;(\/?strong)&gt;/g, '<$1>');
};
Autocomplete.formatGroup = function (suggestion, category) {
return '<div class="autocomplete-group"><strong>' + category + '</strong></div>';
};
Autocomplete.prototype = {
killerFn: null,
@ -671,7 +676,7 @@
category = currentCategory;
return '<div class="autocomplete-group"><strong>' + category + '</strong></div>';
return options.formatGroup(suggestion, category);
};
if (options.triggerSelectOnValidInput && that.isExactMatch(value)) {