Sha256: c8c140228674cb9897bc43e226277e532e11f0730506600f1afdc3e693831e52
Contents?: true
Size: 724 Bytes
Versions: 1
Compression:
Stored size: 724 Bytes
Contents
import { Controller } from "@hotwired/stimulus" import TomSelect from "tom-select" export default class extends Controller { static values = { options: Object, url: String } connect() { this.select = new TomSelect(this.element, { plugins: ['remove_button'], valueField: 'id', labelField: 'name', searchField: 'name', load: (search, callback) => { let url = search ? `${this.urlValue}?q=${search}` : this.urlValue; fetch(url) .then(response => response.json()) .then(json => { callback(json); }).catch(() => { callback(); }); } }) } disconnect() { this.select.destroy() } }
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
madmin-2.0.0 | app/javascript/madmin/controllers/select_controller.js |