Reputation: 1981
I am using this time picker.
Problem is, when I navigate to another page while the time picker is shown, it will still be shown on the next screen when it loads. How do I destroy the timepicker?
Have tried the below but to no avail.
tp.timepicker('destroy');
tp.timepicker('remove');
tp = null;
Upvotes: 1
Views: 1993
Reputation: 611
It is not well documented, but there is a destroy method :
$($elem).timepicker('destroy');
Calling the destroy method should unbind events from the input and remove most of what was instatiated for the timepicker.
Upvotes: 1
Reputation: 10141
Here is the working JSFIDDLE HTML:
<input type="text" style="width: 70px;" id="timepicker" value="" />
<input type="button" value="Destroy it !" id="destroy">
JS:
$(document).ready(function(){
$('#timepicker').timepicker();
$('#destroy').click(function(){
$('#timepicker').timepicker('destroy');
$('#timepicker').timepicker('hide');
});
});
Upvotes: 2