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

TypeError: re.delegate is not a function #288

Closed itd closed 7 years ago

itd commented 7 years ago

Hi,

When I try to make the plugin work with jquery-1.3.2, I get the following error:

TypeError: re.delegate is not a function
http://junk.example.com/jqdrp/jquery.daterangepicker.min.js
Line 7

I'm working on a project that requires jquery 1.3.2. Any tips on how to mitigate the issue?

Thanks, Kurt

Note: Upgrading to a newer version of jquery makes the issue go away.

dtaipov commented 7 years ago

I don't understand the problem very deeply, but it can be fixed fast by removing all .delegate() calls like:

/*box.delegate('.day','click', function(evt)
{
   dayClicked($(this));
});*/

and inserting this code to the box.click(){} block, which is at line 1005:

box.click(function(evt)
{
    if ($(evt.target).is(".day")) {
        dayClicked($(evt.target));
    } else if ($(evt.target).is(".week-number")) {
                weekNumberClicked($(evt.target));
    }
    evt.stopPropagation();
});
holtkamp commented 7 years ago

Fixed by @dtaipov and tagged in https://github.com/longbill/jquery-date-range-picker/releases/tag/0.14.0

itd commented 7 years ago

This fix, along with some work around line 932 (I commented out the function around box.delegate('.day', 'mouseleave', function() seemed to help it work for me.

holtkamp commented 7 years ago

@itd , you sure you updated to 0.14.0? Starting from that version no more delegate calls are used... Have a look yourself:

https://github.com/longbill/jquery-date-range-picker/blob/0.14.0/src/jquery.daterangepicker.js

Or am I missing something?

itd commented 7 years ago

Yes. I see. That is really great! Thank you!