longbill / jquery-date-range-picker

A jQuery plugin that allows user to select a date range
MIT License
1.12k stars 579 forks source link

Event is not working #479

Closed losewin closed 4 years ago

losewin commented 4 years ago

Why is it not working? already tried the .on('datepicker-change') and .bind('datepicker-change') but still won't trigger

var today=new Date()
        today.setDate(today.getDate()+1)
        jQuery('#datepicker').dateRangePicker({
            startDate: today,
            inline:true,
            showTopbar:false,
            container: '.daterangepicker',
            alwaysOpen:true,
            stickyMonths:true,
            // customArrowPrevSymbol:'<i class="fa fa-angle-left"></i>',
            // customArrowNextSymbol:'<i class="fa fa-angle-right"></i>',
            /*hoveringTooltip: function(days, startTime, hoveringTime){
                $('.ifly-widget .departure-picker button.nights').text(days+' Days')
                return days
            }*/
        }).bind('datepicker-change',function(event, obj){
            console.log('change',event, obj)
            // $('departure-selection')
        })

But its working fine on the Demo

losewin commented 4 years ago

This happens because the element does not exists but the container does, which datepicker-change event can't be attached to the jQuery('#datepicker') element