简体   繁体   English

Onclick日关闭bootstrap datepicker

[英]Onclick day close bootstrap datepicker

I want to close datepicker when click on day. 我希望在点击一天时关闭datepicker。 How is this possible in Bootstrap Datepicker? 如何在Bootstrap Datepicker中实现这一点?

Here is the fiddle: 这是小提琴:

http://jsfiddle.net/kGGCZ/17/ http://jsfiddle.net/kGGCZ/17/

$('#dob').datepicker(
{
    endDate:ageDate
}
);

You the auto-close property of the bootstrap date-piker like below 你是bootstrap date-piker的自动关闭属性,如下所示

$('#dob').datepicker(
{
    endDate:ageDate,
    autoclose: true
}
);

I have already updated your js-fiddle 我已经更新了你的js-fiddle

Updated fiddle 更新了小提琴

Note that if you are using Stefan Petre's original version of the Bootstrap Datepicker , the autoclose property will [as of this writing] not work. 请注意,如果您使用Stefan Petre的Bootstrap Datepicker原始版本 ,autoclose属性将[在撰写本文时]不起作用。 In this case, you should do something like this: 在这种情况下,你应该这样做:

$('#myDate').datepicker().on('changeDate', function (e) {
    $('#myDate').datepicker('hide');
});

If you're using eternicode's forked version , the autoclose property will work. 如果您使用的是eternicode的分叉版本 ,则autoclose属性将起作用。

initialize your date picker with option 'autoclose' 使用选项'autoclose'初始化您的日期选择器

$('#dob').datepicker(
{"autoclose": true});

or you can close date picker by using following code also 或者您也可以使用以下代码关闭日期选择器

$('#dob').datepicker().on('changeDate', function (ev) {
    $('#dob').hide();
    });
$('#Date3').datepicker({
        format: "mm-yyyy",
        viewMode: "months",
        minViewMode: "months"
    }).on('changeDate', function (e) {
        $('#Date3').datepicker('hide');
    });

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM