You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
$('#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:
//remove timepicker div$($.timepicker._tpDiv).remove();//unbind all related events$($elem).find('.has-timepicker').unbind('.timepicker');/*$.fn.timepicker is subscribed to the mousedown event for the whole document (default event; no namespace)so we can't undo that but when that event is triggered they first check if there's an instance of thetimepicker ($.timepicker._curInst)*///reset timepicker settings; tell it there's no timepicker instance$.timepicker._curInst=false;
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)
The text was updated successfully, but these errors were encountered:
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.
$('#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)
The text was updated successfully, but these errors were encountered: