longbill / jquery-date-range-picker

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

Eventhandler wil not be remove on destroy #304

Open ChristopherSchaefer opened 7 years ago

ChristopherSchaefer commented 7 years ago

In the init_datepicker()-Function there is a click-event bound to the document.

$(document).bind('click.datepicker', function(e){

But in your destroy-method is no unbind. Please add the unbind to the detroy-method.

$(document).unbind('.datepicker')

Thanks.

holtkamp commented 7 years ago

@ChristopherSchaefer can you provide a PR for that?

Nakilon commented 7 years ago

I guess it's not the only one event that have to be unbinded since I had similar issue about change. Had to do this:

          if ($("#daterangepicker").data("dateRangePicker")) {
            $("#daterangepicker").unbind("datepicker-change");
            $("#daterangepicker").unbind("datepicker-open");
            $("#daterangepicker").unbind("datepicker-closed");
            $("#daterangepicker").data("dateRangePicker").destroy();
          };