Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

on clear not binding #246

Open
td234 opened this issue May 22, 2024 · 0 comments
Open

on clear not binding #246

td234 opened this issue May 22, 2024 · 0 comments

Comments

@td234
Copy link

td234 commented May 22, 2024

Describe the bug
I am trying to bind the 'select' and 'clear' events to my own functions. I can successfully bind 'select' but 'clear' does not bind. The online docs say 'clear' is an event, but the core/README does not list 'clear' as an event. I need a way to call a function when someone clicks Clear.

To Reproduce
this.picker = new easepick.create({
element: document.getElementById(arrivalId),
calendars: 2,
grid: 2,
format: 'MM-DD-YYYY',
locale: {
cancel: 'Clear'
},
autoApply: false,
css: [
'/lib/css/easepick.css'
],
plugins: [RangePlugin, LockPlugin],
RangePlugin: {
tooltipNumber(num) {
return num - 1;
},
locale: {
one: 'night',
other: 'nights',
cancel: 'Clear'
},
elementEnd: #${departureId}
},
LockPlugin: {
minDate: new Date(),
maxDate: eighteenMonthsLater,
minDays: 2,
inseparable: true,
filter(date, picked) {
if (!Array.isArray(bookedDates) || bookedDates.length === 0) {
return false;
}
if (picked.length === 1) {
const incl = date.isBefore(picked[0]) ? '[)' : '(]';
return !picked[0].isSame(date, 'day') && date.inArray(bookedDates, incl);
}

                return date.inArray(bookedDates, '[)');
            },
        },
        setup: (picker)=> {
            picker.on('clear', this.handleClear.bind(this));
            picker.on('select', this.handleApply.bind(this));
        },
        ...options
    });

handleApply(e) {
    console.log('handleApply triggered');

} handleClear(e) {
console.log('handleClear triggered');
}

Expected behavior
I can see the handleApply console.log, but not the handleClear.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant