P. Danek
P. Danek

Reputation: 9

Easepick - dynamically change minDate

I have 2 easepick calendars and want to dynamically change minDate - if first calendar changed, test if date is bigger than checkout date and if so change minDate for checkout calendar. But when I call pickerOut.renderAll(); LockPlugin is ignored and I can select all the dates. Any ideas what I did wrong? Thank you.

    const picker = new easepick.create({
        element: "#checkin",
        format: "DD.MM.YYYY",
        grid: 2,
        calendars: 2,
        LockPlugin: {
            minDate: new Date(),
        },
        setup(picker) {
            picker.on('select', (e) => {
                if (pickerOut.getDate() <= e.detail.date) {
                    const newDate = new Date(e.detail.date);
                    newDate.setDate(e.detail.date.getDate() + 1);
                    pickerOut.setDate(newDate);
                    pickerOut.PluginManager.getInstance('LockPlugin').options.minDate = newDate;
                    pickerOut.renderAll();
                }
            });
        },
        plugins: ["LockPlugin"]
    });

    const pickerOut = new easepick.create({
        element: "#checkout",
        format: "DD.MM.YYYY",
        grid: 2,
        calendars: 2,
        lang: pickerLng,
        LockPlugin: {
            minDate: new Date(),
        },
        plugins: ["LockPlugin"],
    });

Upvotes: 0

Views: 77

Answers (0)

Related Questions