jQuery bootstrap datepicker 选项似乎不起作用(vitalets 的 datepicker)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19363398/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 23:47:24  来源:igfitidea点击:

bootstrap datepicker option doesn't seem work (datepicker by vitalets)

jquerytwitter-bootstrapdatepicker

提问by Ricki Vandenbroek

I included everything but it doesn't seem work with the options, no example for a newbiew is a pain.. help..

我包含了所有内容,但它似乎不适用于这些选项,对于新手来说没有任何示例是痛苦的.. 帮助..

html

html

<input type="text" class="form-control  datepicker" id="datepicker" data-date-format="dd/mm/yyyy" />

js

js

$('#datepicker').datepicker({
        autoclose: true,
        todayBtn: true,
        todayHighlight: true
});

github reference: https://github.com/vitalets/bootstrap-datepicker#autoclose

github 参考:https: //github.com/vitalets/bootstrap-datepicker#autoclose

回答by Praveen

Your code is fine,

你的代码没问题

check this JSFiddlethe datepicker is getting closed when I select a date.

检查这个JSFiddle当我选择一个日期时,日期选择器正在关闭。

autoclose: true  //this will work with vitalets

I guess the following is the possible reason:

我想可能的原因如下:

1) Might given wrong bootstrap.datepicker.js

1) 可能给出错误的bootstrap.datepicker.js

<script src="http://vitalets.github.io/bootstrap-datepicker/bootstrap-datepicker/js/bootstrap-datepicker.js"></script>

Make sure your path is right

确保你的路径是正确的

回答by Xingda Wang

todayBtn: truedirects the button to only bring today into view, not select it. If you want the button to actually change the date selected, use:

todayBtn: true指示按钮只显示今天,而不是选择它。如果您希望按钮实际更改所选日期,请使用:

todayBtn: "linked"

See it from: https://github.com/uxsolutions/bootstrap-datepicker/issues/314

请参阅:https: //github.com/uxsolutions/bootstrap-datepicker/issues/314

回答by Mukesh Chapagain

Try this:

尝试这个:

$('.datepicker').datepicker()
.on('changeDate', function(ev){                 
    $('.datepicker').datepicker('hide');
});

Update:

更新:

autocloseworks fine with the datepicker present in the following repo:

autoclose与以下 repo 中存在的日期选择器一起工作正常:

https://github.com/eternicode/bootstrap-datepicker

https://github.com/eternicode/bootstrap-datepicker