Files
manyfold/app/frontend/javascript/controllers/collection_input_controller.ts
T

24 lines
477 B
TypeScript

import { Controller } from '@hotwired/stimulus'
import TomSelect from 'tom-select'
// Connects to data-controller="collection-input"
export default class extends Controller {
tomSelect: TomSelect | null
connect (): void {
this.tomSelect = new TomSelect((this.element as HTMLSelectElement), {
plugins: ['remove_button']
})
}
disconnect (): void {
this.tomSelect?.destroy()
}
reconnect (): void {
this.disconnect()
this.connect()
}
}