2
0
mirror of https://github.com/devbridge/jQuery-Autocomplete.git synced 2024-11-09 23:01:00 +00:00

issue #451, put formatGroup available in option

This commit is contained in:
Michaël Marinetti 2016-07-20 16:38:29 +02:00
parent 3b49827db4
commit 937574fa0d

View File

@ -67,6 +67,7 @@
deferRequestBy: 0,
params: {},
formatResult: Autocomplete.formatResult,
formatGroup: Autocomplete.formatGroup,
delimiter: null,
zIndex: 9999,
type: 'GET',
@ -143,6 +144,18 @@
.replace(/&lt;(\/?strong)&gt;/g, '<$1>');
};
Autocomplete.formatGroup = function (suggestion, index) {
var currentCategory = suggestion.data[groupBy];
if (category === currentCategory){
return '';
}
category = currentCategory;
return '<div class="autocomplete-group"><strong>' + category + '</strong></div>';
};
Autocomplete.prototype = {
killerFn: null,
@ -657,17 +670,7 @@
beforeRender = options.beforeRender,
html = '',
category,
formatGroup = function (suggestion, index) {
var currentCategory = suggestion.data[groupBy];
if (category === currentCategory){
return '';
}
category = currentCategory;
return '<div class="autocomplete-group"><strong>' + category + '</strong></div>';
};
formatGroup = options.formatGroup;
if (options.triggerSelectOnValidInput && that.isExactMatch(value)) {
that.select(0);