Sha256: 66329643de7982a0861a0b3cf2010e845f20e9169fc60aa2d2e1bcde1e529dcf
Contents?: true
Size: 761 Bytes
Versions: 1
Compression:
Stored size: 761 Bytes
Contents
// app/javascript/controllers/ts/search_controller.js import { Controller } from "@hotwired/stimulus" import { get } from '@rails/request.js' import TomSelect from "tom-select" // Connects to data-controller="ts--search" export default class extends Controller { static values = { url: String } connect() { var config = { plugins: ['clear_button'], valueField: 'value', load: (q, callback) => this.search(q, callback) } new TomSelect(this.element, config) } async search(q, callback) { const response = await get(this.urlValue, { query: { q: q }, responseKind: 'json' }) if (response.ok) { const list = await response.json callback(list) } else { callback() } } }
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
tybo-0.0.3 | lib/app/javascript/controllers/ts/search_controller.js |