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

别说谁变了你拦得住时间么 提交于 2019-12-11 12:18:53

问题


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

html

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

js

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

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


回答1:


Your code is fine,

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

autoclose: true  //this will work with vitalets

I guess the following is the possible reason:

1) Might given wrong bootstrap.datepicker.js

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

Make sure your path is right




回答2:


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

todayBtn: "linked"

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




回答3:


Try this:

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

Update:

autoclose works fine with the datepicker present in the following repo:

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



来源:https://stackoverflow.com/questions/19363398/bootstrap-datepicker-option-doesnt-seem-work-datepicker-by-vitalets

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!