-
-
Save whoisthisstud/fc855fa491794fe3e62ef4553942b459 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <script> | |
| document.addEventListener('alpine:init', () => { | |
| Alpine.data('flatpickr', () => ({ | |
| selectedDate: '', | |
| init() { | |
| const fp = new window.flatpickr(this.$refs.picker, {}); | |
| if (typeof window.flatpickrInputs === 'undefined') { | |
| window.flatpickrInputs = []; | |
| } | |
| window.flatpickrInputs.push(fp); | |
| fp.config.onChange.push((a, dateStr) => { | |
| this.selectedDate = dateStr; | |
| }); | |
| } | |
| }); | |
| }); | |
| </script> | |
| <div x-data="flatpickr"> | |
| <input type="text" x-model="selectedDate" x-ref="flatpickrInput"> | |
| </div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment