mcServerWebsite/app/assets/controllers/tom-select_controller.js
2026-04-09 15:23:15 +02:00

21 lines
590 B
JavaScript

// assets/controllers/tom-select_controller.js
import { Controller } from '@hotwired/stimulus';
import TomSelect from 'tom-select';
export default class extends Controller {
connect() {
new TomSelect(this.element, {
plugins: ['remove_button'],
placeholder: this.element.dataset.placeholder ?? 'Rechercher une dépendance...',
maxOptions: null,
wrapperClass: 'ts-wrapper form-tom-select',
});
}
disconnect() {
if (this.element.tomselect) {
this.element.tomselect.destroy();
}
}
}