选择日期后引导日期选择器不会自动关闭 [英] Bootstrap datepicker not close automatically after picking a date

查看:34
本文介绍了选择日期后引导日期选择器不会自动关闭的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用最新的 Bootstrap datepicker.js.一切正常,只是当我从下拉列表中选择一个日期时,它不会自动关闭它.我在网上搜索并尝试在我的 javascript 中使用以下函数,如下所示:

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 use the following function in my javascript like the following:

 $('#selectDate').datepicker({
    autoclose: true
}).on('changeDate', function (ev) {
    (ev.viewMode == 'days') ? $(this).datepicker('hide') : '';      
});

但是当我使用 Google Chrome Dev 工具时,我意识到 ev.viewmode 是未定义的.我不知道如何前进.

but when i use Google Chrome Dev tools, I realized that ev.viewmode was undefined. I am not sure how to move forward.

推荐答案

我添加了 autoclose: true,(在最后加上 半逗号 并且它有效)>

I added autoclose: true, (with semi comma at the end and it works)

 $('.datepicker').datepicker({
    format: 'dd/mm/yyyy',
    todayHighlight:'TRUE',
    autoclose: true,
})

这篇关于选择日期后引导日期选择器不会自动关闭的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆