bootstrap-datepicker: AutoClose not working

Hi, i use the autoclose method but this not working in Chrome: js:

        $(document).ready(function () {                                  
            $('.datepicker').datepicker({
                format: "dd/mm/yyyy",
                autoclose: true
            });

        });        

html:

<input class="datepicker valid" data-val="true" data-val-date="El campo Vencimiento debe ser una fecha." id="FirstMaturiy" name="FirstMaturiy" readonly="readonly" type="text" value="">

Thanks for your help.

About this issue

  • Original URL
  • State: closed
  • Created 11 years ago
  • Comments: 41 (6 by maintainers)

Most upvoted comments

if you are using html 5 than you can use (data-date-autoclose=“true” ) for auto closing other-wise you can use autoclose: true in your datepicker directive.

On Fri, Jun 27, 2014 at 2:40 PM, thearyoun notifications@github.com wrote:

I use autoclose; true for datetimepicker in bootstrap 2.3.2 it doesn’t work. how to solve it.

— Reply to this email directly or view it on GitHub https://github.com/eternicode/bootstrap-datepicker/issues/500#issuecomment-47323025 .

Don’t use class="datepicker" on your input or it will ignore any options you pass. Just do something like

<input class="datepickerx" type="text" /> and then $(".datepickerx").datepicker({ autoclose: true });

I’ve solved it by removing the data-provide=“datepicker” from the outter div. After that autoclose worked and even the todayHighlight:true start working too.

thank you, that worked for me $(‘.datepicker’).datepicker().on(‘changeDate’, function (ev) { $(this).datepicker(‘hide’); });;

I use the 1.10.1 version now. But I have the same behavior (The calendar not close on lost focus or select date) with the version 1.7.10.1

I not have errors in console.

Your example in jsfiddle.net don’t work. Only see a input disabled. I use Chrome with the version 27.0.1453.110 m.

I have the folowing code in document ready:

$('.datepicker').datepicker({
    format: "dd/mm/yyyy",
    autoclose: true,
}).on('changeDate', function (ev) {
    $(this).datepicker('hide');
});;

with the changeDate event I force the close Calendar on select date. If not use the changeDate, te calendar not close.

Thanks for your help