mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-17 13:08:16 -06:00
Fix initialization of TomSelect dropdowns after HTMX loading
This commit is contained in:
parent
fa4f4893a3
commit
a78fb8033c
BIN
netbox/project-static/dist/netbox.js
vendored
BIN
netbox/project-static/dist/netbox.js
vendored
Binary file not shown.
BIN
netbox/project-static/dist/netbox.js.map
vendored
BIN
netbox/project-static/dist/netbox.js.map
vendored
Binary file not shown.
@ -1,4 +1,3 @@
|
|||||||
import { getElements, isTruthy } from './util';
|
|
||||||
import { initButtons } from './buttons';
|
import { initButtons } from './buttons';
|
||||||
import { initSelects } from './select';
|
import { initSelects } from './select';
|
||||||
import { initObjectSelector } from './objectSelector';
|
import { initObjectSelector } from './objectSelector';
|
||||||
@ -15,16 +14,5 @@ function initDepedencies(): void {
|
|||||||
* elements.
|
* elements.
|
||||||
*/
|
*/
|
||||||
export function initHtmx(): void {
|
export function initHtmx(): void {
|
||||||
for (const element of getElements('[hx-target]')) {
|
document.addEventListener('htmx:afterSettle', initDepedencies);
|
||||||
const targetSelector = element.getAttribute('hx-target');
|
|
||||||
if (isTruthy(targetSelector)) {
|
|
||||||
for (const target of getElements(targetSelector)) {
|
|
||||||
target.addEventListener('htmx:afterSettle', initDepedencies);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (const element of getElements('[hx-trigger=load]')) {
|
|
||||||
element.addEventListener('htmx:afterSettle', initDepedencies);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -42,7 +42,7 @@ function renderItem(data: TomOption, escape: typeof escape_html) {
|
|||||||
|
|
||||||
// Initialize <select> elements which are populated via a REST API call
|
// Initialize <select> elements which are populated via a REST API call
|
||||||
export function initDynamicSelects(): void {
|
export function initDynamicSelects(): void {
|
||||||
for (const select of getElements<HTMLSelectElement>('select.api-select')) {
|
for (const select of getElements<HTMLSelectElement>('select:not(.tomselected).api-select')) {
|
||||||
new DynamicTomSelect(select, {
|
new DynamicTomSelect(select, {
|
||||||
...config,
|
...config,
|
||||||
valueField: VALUE_FIELD,
|
valueField: VALUE_FIELD,
|
||||||
|
@ -7,7 +7,7 @@ import { getElements } from '../util';
|
|||||||
// Initialize <select> elements with statically-defined options
|
// Initialize <select> elements with statically-defined options
|
||||||
export function initStaticSelects(): void {
|
export function initStaticSelects(): void {
|
||||||
for (const select of getElements<HTMLSelectElement>(
|
for (const select of getElements<HTMLSelectElement>(
|
||||||
'select:not(.api-select):not(.color-select)',
|
'select:not(.tomselected):not(.api-select):not(.color-select)',
|
||||||
)) {
|
)) {
|
||||||
new TomSelect(select, {
|
new TomSelect(select, {
|
||||||
...config,
|
...config,
|
||||||
@ -23,7 +23,7 @@ export function initColorSelects(): void {
|
|||||||
)}"></span> ${escape(item.text)}</div>`;
|
)}"></span> ${escape(item.text)}</div>`;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const select of getElements<HTMLSelectElement>('select.color-select')) {
|
for (const select of getElements<HTMLSelectElement>('select:not(.tomselected).color-select')) {
|
||||||
new TomSelect(select, {
|
new TomSelect(select, {
|
||||||
...config,
|
...config,
|
||||||
render: {
|
render: {
|
||||||
|
Loading…
Reference in New Issue
Block a user