jquery-date-range-picker icon indicating copy to clipboard operation
jquery-date-range-picker copied to clipboard

Error in window resize when binding events

Open jcubic opened this issue 6 years ago • 3 comments
trafficstars

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);

jcubic avatar Dec 06 '18 17:12 jcubic

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

monovertex avatar Dec 29 '18 17:12 monovertex

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.

jcubic avatar Dec 29 '18 19:12 jcubic

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.

jcubic avatar Jan 07 '19 15:01 jcubic