longbill/jquery-date-range-picker

Error in window resize when binding events

Opened this issue · 3 comments

There is error in the code, the docs say to use this to bind events:

$('#dom-id').dateRangePicker();

but this will create window resize event with box as undefined and will throw exception.

This is always added:

$(window).on('resize.datepicker', calcPosition);

even if you request for picker object to bind events. To fix the issue, is to use this code instead:

$('#dom-id').bind('datepicker-change', onChange);

I'm not sure I understand what the issue is here. Can you provide a JSFiddle that showcases the bug?

If you follow the API documentation, you have not working widget. so change event don't work at all as per API docs and instead you have exception in console. Will try to create fiddle with error using wrong API from docs. But right now I don't have access to the code I was using. It's on my work laptop.

Here is fiddle https://jsfiddle.net/zcgtLehf/
if you call this

$('#dom-id')
.dateRangePicker()
.bind('datepicker-first-date-selected', function(event, obj) {
});

as per docs. And as per code, the plugin will be initialized twice but second time it will be broken. Open dev tools. When you focus the input, it will throw exception.