laravel - Set Livewire value in JavaScript with defer - Stack Overflow

I have a date picker inside a Livewire ponent which I'm setting the value of via JavaScript as the

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?

Share Improve this question edited Dec 10, 2021 at 18:49 valiano 18.7k7 gold badges71 silver badges83 bronze badges asked Dec 9, 2021 at 12:31 DanCDanC 431 silver badge6 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 5

Use:

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

The third argument of true is for defer.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745126627a4612728.html

相关推荐

  • laravel - Set Livewire value in JavaScript with defer - Stack Overflow

    I have a date picker inside a Livewire ponent which I'm setting the value of via JavaScript as the

    4小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信