admin管理员组文章数量:1277529
How to get current viewMode
property from "Bootstrap Datepicker"?
I initialize the control with viewMode= 'years'
and I want to close datepicker on changeDate
event, only when viewMode='days'
.
The user selects a year, then a month, and finally a day. In that moment the control must be closed.
This is the code:
$("#date").datepicker(
{viewMode: 'years',
format: 'dd/mm/yyyy'
});
$('#date').on('changeDate', function (ev) {
//close when viewMode='0' (days)
})
Can anyone help?
How to get current viewMode
property from "Bootstrap Datepicker"?
I initialize the control with viewMode= 'years'
and I want to close datepicker on changeDate
event, only when viewMode='days'
.
The user selects a year, then a month, and finally a day. In that moment the control must be closed.
This is the code:
$("#date").datepicker(
{viewMode: 'years',
format: 'dd/mm/yyyy'
});
$('#date').on('changeDate', function (ev) {
//close when viewMode='0' (days)
})
Can anyone help?
Share Improve this question edited Feb 22, 2013 at 16:43 Gonzalo asked Jan 22, 2013 at 11:20 GonzaloGonzalo 2,8767 gold badges31 silver badges42 bronze badges2 Answers
Reset to default 7Check this : http://jsfiddle/nAXnM/
HTML
<input type="text" class="span2" value="02/16/12" data-date-format="mm/dd/yy" id="dp2" >
JS
$("#dp2").datepicker({
viewMode: 'years',
format: 'dd/mm/yyyy'
});
$('#dp2').on('changeDate', function (ev) {
//close when viewMode='0' (days)
if(ev.viewMode === 'days'){
$('#dp2').datepicker('hide');
}
})
If you're using the forked version of Bootstrap Datepicker, to close the UI widget when a date is selected, set the autoclose
option to true
:
$("#date").datepicker({
autoclose: true
});
本文标签: javascriptHow to get current viewMode property from quotBootstrap DatepickerquotStack Overflow
版权声明:本文标题:javascript - How to get current viewMode property from "Bootstrap Datepicker" - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741240381a2363858.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论