xdan / periodpicker

Empty repository for paid periodpicker version
14 stars 2 forks source link

timepicker problem when using many #77

Open puschie286 opened 6 years ago

puschie286 commented 6 years ago

i get an error on some timepicker when there are more than 4 on a page:

Uncaught TypeError: Cannot read property 'length' of undefined
  TimePicker.setTime    
  (anonymous function)  
  each  
  each  
  $.fn.TimePicker   
  TimePickerAlone.show  
  (anonymous function)  
  dispatch  
  elemData.handle   

jquery.timepicker.js:194

the boxes variable is undefined.

puschie286 commented 6 years ago

found the problem : you need to destroy all parts ( and references ), the jquery objects on the startinput

my temp solution is:

TimePicker.prototype.destroy = function () {
        var that = this;
        $(window)
            .off('mouseup.xdsoft' + that.uniqueid + ' touchend.xdsoft' + that.uniqueid)
            .off('mousemove.xdsoft' + that.uniqueid + ' touchmove.xdsoft' + that.uniqueid);
        that.timepicker.remove();
        that.startinput.removeData( 'timepickeralone' );
        $.each( that.startinput[0], function( Key, Value ) {
            if( !Key.startsWith( 'jQuery' ) ) return;
            delete that.startinput[0][Key];
        });
        delete that.timepicker;
        delete that.boxes;
        delete that.currentime;
        delete that.startinput;
    };