Laravel 8: Livewire

C++ JAVA
Post Reply
User avatar
dakata__92
Web-tourist
Web-tourist
Reactions: 1
Posts: 3398
Joined: Tue Aug 02, 2011 7:24 pm
Answers: 128

Laravel 8: Livewire

Post by dakata__92 »

Налага ми се да използвам тази библиотека. Всичко е точно, докато стигнах до избирането на дата. Оказа се, че daterangepicker подава нулева стойност. Не се попълва стойността и това е....

resources/views/livewire/form.blade.php

Code: Select all

<div class="position-relative w-md-400px me-md-2">
                        <i class="bi bi-calendar position-absolute top-50 translate-middle ms-6"></i>
                        <x-inputs.date-range-picker
                            class="form-control form-control-solid ps-10"
                        />
                    </div>
resources/views/components/inputs/date-range-picker.php

Code: Select all

<input type="text"
       id="kt_date_range_picker"
       data-kt-date-range-picker="@this"
       {{ $attributes }}
/>
@push('body.script')
    <script>
        var ktDateRangePickerFormat = "YYYY-MM-DD HH:mm:ss";
        var ktDateRangePickerId = "#kt_date_range_picker";
        $(ktDateRangePickerId).daterangepicker({
            timePicker: true,
            timePickerSeconds: true,
            timePicker24Hour: true,
            showDropdowns: true,
            startDate: moment().set({hour: 0, minute: 0, second: 0}).format(ktDateRangePickerFormat),
            endDate: moment().set({hour: 23, minute: 59, second: 59}).format(ktDateRangePickerFormat),
            minYear: parseInt(moment().format('YYYY')) - 1,
            maxYear: parseInt(moment().format('YYYY')) + 1,
            locale: {
                separator: '/',
                format: ktDateRangePickerFormat
            }
        }).on('change.daterangepicker', function() {
            var dateRangePicker = $(this).data('ktDateRangePicker');
            eval(dateRangePicker).set('date_range', $(ktDateRangePickerId).val());
        });
    </script>
@endpush
joTunkiq
Потребител
Потребител
Reactions: 0
Posts: 832
Joined: Tue Dec 25, 2012 10:03 am
Answers: 142
Contact:

Re: Laravel 8: Livewire

Post by joTunkiq »

На кратко използвай hook-вете на livewire, а не тези на jquery, защото зареждат по различно време и ще се вкараш в едни филми със settimeout и прочия;
Помощен линк: https://stackoverflow.com/a/67481201
Post Reply