Is there a way to destroy the Bootstrap datepicker dynamically updating its options like format, beforeShowDay, etc.?
I know that the jQuery UI datepicker has a destroy method but Bootstrap's has not. It only has the .('remove')
method but its not working.
My goal is to modify the options of the datepicker when changing an input, for example:
$('#employee').change( function() {
$('#date').datepicker('destroy'); //not working 'cause bootstrap hasnt a destroy method
$('#date').hide();
});
Then I call the initialize function when the input changes:
function updateCalendar(){
$('#date').datepicker({
format:"dd/mm/yyyy",
beforeShowDay: updateC //function that modifies the available days to show
});
}
$('.datepicker').datepicker('remove');
Make sure you have your date picker object in DOM before removing it. Without removing you can hide the calendar and change the format of date and update it .
$('.datepicker').datepicker('update');