Sha256: 0de3669c57a4706a692c55145590cb11e4293dfe7a90fd0ff1fc2f0a5b5e3aa1
Contents?: true
Size: 885 Bytes
Versions: 2
Compression:
Stored size: 885 Bytes
Contents
import { Controller } from "@hotwired/stimulus" // Connects to data-controller="flatpickr" export default class extends Controller { connect() { console.log(`flatpickr connected: ${this.element}`) self.picker = new flatpickr(this.element, this.#buildOptions()) this.element.setAttribute("data-action", "turbo:morph-element->flatpickr#reconnect") } disconnect() { self.picker.destroy() self.picker = null } reconnect() { this.disconnect() this.connect() } #buildOptions() { let options = { altInput: true } if (this.element.attributes.type.value == "datetime-local") { options.enableTime = true } else if (this.element.attributes.type.value == "time") { options.enableTime = true options.noCalendar = true // options.time_24hr = true // options.altFormat = "H:i" } return options } }
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
plutonium-0.16.0 | src/js/controllers/flatpickr_controller.js |
plutonium-0.15.24 | src/js/controllers/flatpickr_controller.js |