1

I have a date picker inside a Livewire component which I'm setting the value of via JavaScript as the Bootstrap datepicker does not update the value automatically:

$('.datepicker').datetimepicker({
        format: 'DD/MM/YYYY',
        icons: {
            time: "fa fa-clock-o",
            date: "fa fa-calendar",
            up: "fa fa-chevron-up",
            down: "fa fa-chevron-down",
            previous: 'fa fa-chevron-left',
            next: 'fa fa-chevron-right',
            today: 'fa fa-screenshot',
            clear: 'fa fa-trash',
            close: 'fa fa-remove'
        }
    }).on('dp.change', function (e) {
        this.due_date = e.target.value;
    });

This works great, however the picker disappears when the Livewire update occurs (as expected). Is there a way to update due_date via JavaScript but have it deferred in the same way as setting wire:model.defer="due_date" so it's sent on the next network update rather than instantly?

1 Answer 1

5

Use:

@this.set('prop', value, true)

The third argument of true is for defer.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.