flowbite-datepicker icon indicating copy to clipboard operation
flowbite-datepicker copied to clipboard

Setting options when using Livewire

Open blunde opened this issue 1 year ago • 1 comments

How can I set options on a datepicker that is already initialized ?

Using Laravel 10, Livewire 3, npm

blunde avatar Nov 30 '23 21:11 blunde

The documentation is clear, you just need extra code to enable in livewire 3

page.blade.php

<script data-navigate-once>
    document.addEventListener('livewire:navigated', () => {
        const Datepicker = document.getElementById('date');

        if (!Datepicker) return;

        new Datepicker(Datepicker, {
            format: 'yyyy/mm/dd',
            buttons: true, // not working
            autohide: true,
            title: 'This is a datepicker',
        }); 
    });
</script>

app.js

import Datepicker from 'flowbite-datepicker/Datepicker';

window.Datepicker = Datepicker;

Livewire.start()

cinderjk avatar Jan 19 '24 07:01 cinderjk