mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
add javascript
This commit is contained in:
23
netbox/project-static/src/select/static.ts
Normal file
23
netbox/project-static/src/select/static.ts
Normal file
@ -0,0 +1,23 @@
|
||||
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,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user