I use the latest Bootstrap datepicker.js. All works fine except that when I pick a date from the drop down, it does not automatically close it. I searched web and tried to u
I added autoclose: true, (with semi comma at the end and it works)
$('.datepicker').datepicker({
format: 'dd/mm/yyyy',
todayHighlight:'TRUE',
autoclose: true,
})
Try this. It's work for me.
<input data-auto-close="true" type="text" class="datepicker-here"/>
None of the above worked for me, however overriding the datepicker default option worked like a charm, and is a one-liner:
$.fn.datepicker.defaults.autoclose = true;
Try this:
$('#selectDate').datepicker()
.on('changeDate', function(ev){
$('#selectDate').datepicker('hide');
});
Update:
autoclose
works fine when you use the updated version of datepicker present on github:
https://github.com/eternicode/bootstrap-datepicker
If you have multiple textboxes for which you have applied datepicker, then old solution might cause problem, Please try this instead,
$('.datepicker').datepicker({
format: "dd/mm/yyyy",
autoclose: true,
}).on('changeDate', function (ev) {
$(this).datepicker('hide');
});
Look out this, https://github.com/eternicode/bootstrap-datepicker/issues/500
Note: Do not forget, we are using class selector of jquery, so you need to apply datepicker class to your textbox.
This worked for me
$(".date-picker").change(function() {
setTimeout(function() {
$(".date-picker").datepicker('hide');
$(".date-picker").blur();
}, 50);
});