added showValueBeforeLabel option
This commit is contained in:
parent
603ddb9323
commit
a554125f3e
@ -84,6 +84,9 @@ A callback that is fired every time an item is selected. It receives an object i
|
||||
**showValue**:
|
||||
If set to true, will display the value of the entry after the label in the dropdown list.
|
||||
|
||||
**showValueBeforeLabel**
|
||||
If set to true and **`showValue`** also set to true, the value will be displayed before the label.
|
||||
|
||||
**treshold**:
|
||||
The number of characters that need to be typed on the input in order to trigger the autocomplete. Default is 4.
|
||||
|
||||
|
@ -6,6 +6,7 @@ const DEFAULTS = {
|
||||
label: 'label',
|
||||
value: 'value',
|
||||
showValue: false,
|
||||
showValueBeforeLabel: false,
|
||||
};
|
||||
|
||||
class Autocomplete {
|
||||
@ -77,8 +78,12 @@ class Autocomplete {
|
||||
}
|
||||
|
||||
if (this.options.showValue) {
|
||||
if (this.options.showValueBeforeLabel) {
|
||||
label = `${item.value} ${label}`;
|
||||
} else {
|
||||
label += ` ${item.value}`;
|
||||
}
|
||||
}
|
||||
|
||||
return ce(`<button type="button" class="dropdown-item" data-label="${item.label}" data-value="${item.value}">${label}</button>`);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user