Fix object selector

This commit is contained in:
Jeremy Stretch 2024-03-04 14:06:15 -05:00
parent e966bd38c5
commit 5e5acbfda8
5 changed files with 9 additions and 8 deletions

Binary file not shown.

Binary file not shown.

View File

@ -18,11 +18,12 @@ function handleSelection(link: HTMLAnchorElement): void {
const value = link.getAttribute('data-value');
//@ts-ignore
target.slim.setData([
{text: label, value: value}
]);
const change = new Event('change');
target.dispatchEvent(change);
target.tomselect.addOption({
id: value,
display: label,
});
//@ts-ignore
target.tomselect.addItem(value);
}

View File

@ -20,7 +20,7 @@ function renderOption(data: TomOption, escape: typeof escape_html) {
// Initialize <select> elements which are populated via a REST API call
export function initDynamicSelects(): void {
for (const select of getElements<HTMLSelectElement>('select.api-select')) {
for (const select of getElements<HTMLSelectElement>('select.api-select:not(.tomselected)')) {
new DynamicTomSelect(select, {
...config,
valueField: VALUE_FIELD,

View File

@ -7,7 +7,7 @@ import { getElements } from '../util';
// Initialize <select> elements with statically-defined options
export function initStaticSelects(): void {
for (const select of getElements<HTMLSelectElement>(
'select:not(.no-ts):not(.api-select):not(.color-select):not([size])',
'select:not(.tomselected):not(.no-ts):not([size]):not(.api-select):not(.color-select)',
)) {
new TomSelect(select, {
...config,
@ -17,7 +17,7 @@ export function initStaticSelects(): void {
// Initialize color selection fields
export function initColorSelects(): void {
for (const select of getElements<HTMLSelectElement>('select.color-select')) {
for (const select of getElements<HTMLSelectElement>('select.color-select:not(.tomselected)')) {
new TomSelect(select, {
...config,
render: {