问题
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