alumuko / vanilla-datetimerange-picker

A JavaScript component that is a date & time range picker, no need to build, no dependencies except Moment.js, that is based on Dan Grossman's bootstrap-daterangepicker.
MIT License
148 stars 17 forks source link

fix: event should be fired from the element the date picker is attached to #17

Open mfazekas opened 8 months ago

mfazekas commented 8 months ago

Instead of

    window.addEventListener('apply.daterangepicker', function (ev) {
        console.log(ev.detail.startDate.format('YYYY-MM-DD'));
        console.log(ev.detail.endDate.format('YYYY-MM-DD'));
    });

We should be able to write:

   new DateRangePicker(element...)

    element.addEventListener('apply.daterangepicker', function (ev) {
        console.log(ev.detail.startDate.format('YYYY-MM-DD'));
        console.log(ev.detail.endDate.format('YYYY-MM-DD'));
    });