Bootstrap datepicker not close automatically after picking a date

前端 未结 12 1597
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-24 12:41

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

12条回答
  •  离开以前
    2020-12-24 13:27

    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.

提交回复
热议问题