I have a date picker inside a Livewire ponent 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?
I have a date picker inside a Livewire ponent 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
Reset to default 5Use:
@this.set('prop', value, true)
The third argument of true
is for defer.