Sha256: 86927927ea64e41e9ea711a33712426f47692baeb623476943372c544e98957e
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}`) this.picker = new flatpickr(this.element, this.#buildOptions()) this.element.setAttribute("data-action", "turbo:morph-element->flatpickr#reconnect") } disconnect() { this.picker.destroy() this.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.3 | src/js/controllers/flatpickr_controller.js |
plutonium-0.16.1 | src/js/controllers/flatpickr_controller.js |