mirror of
https://github.com/netbox-community/netbox.git
synced 2025-12-28 15:50:40 +00:00
24 lines
629 B
TypeScript
24 lines
629 B
TypeScript
|
|
import SlimSelect from 'slim-select';
|
||
|
|
|
||
|
|
export function initStaticSelect() {
|
||
|
|
const elements = document.querySelectorAll(
|
||
|
|
'.netbox-select2-static',
|
||
|
|
) as NodeListOf<HTMLSelectElement>;
|
||
|
|
|
||
|
|
for (const select of elements) {
|
||
|
|
if (select !== null) {
|
||
|
|
const label = document.querySelector(`label[for=${select.id}]`) as HTMLLabelElement;
|
||
|
|
let placeholder;
|
||
|
|
if (label !== null) {
|
||
|
|
placeholder = `Select ${label.innerText.trim()}`;
|
||
|
|
}
|
||
|
|
new SlimSelect({
|
||
|
|
select,
|
||
|
|
allowDeselect: true,
|
||
|
|
deselectLabel: `<i class="bi bi-x-circle"></i>`,
|
||
|
|
placeholder,
|
||
|
|
});
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|