Open adam-lynch opened 11 years ago
Hi,
There is actually a "destroy" option that remove the timepicker classes from the input and unbind events : $($elem).timepicker('destroy');
should work.
It will not unset the _curInst because the function _destroyTimepicker function does not check if it is currently showing. However if the user click a close button or something outside a showing timepicker, The _hideTimepicker will be called and the _curInst will be set to null.
Sorry, must've missed that in the documentation.
Sounds good. I'll swap out my code for this next week and let you know if anything unexpected happens.
$('#timepicker-input').timepicker('remove')
would be nice.I was troubleshooting an issue where we having where we add inputs to the DOM, initialize the timepicker on them, then remove them from the DOM, then add some other inputs to the DOM, initialize the timpicker on them... then the timepicker would show but a click on a date wouldn't do anything.
That isn't the reason for this issue. I decided to completely remove the timepicker when the inputs are removed from the DOM*, and the best way I found to achieve this was the following:
It would've been much nicer if I could've just had
$($elem).find('.has-timepicker').timepicker('remove')
or (because the former is per field)$.timepicker.remove()
to completely remove the timepicker instance and event handling.* - well, when the modal they're in is hidden actually (the hidden modal will never be used again, it will most likely be replaced by another modal containing other inputs)