Bootstrap Datetimepicker - 禁用几十年视图模式

Sar*_*rpe 5 jquery datetimepicker twitter-bootstrap bootstrap-datetimepicker eonasdan-datetimepicker

当用户多次单击视图标题时,预期行为是:天 -> 月 -> 年 -> 几十年。我需要禁用几十年视图(附有屏幕截图)。这样做用户无法进一步进入“年”视图模式。

在此输入图像描述

Sar*_*rpe 2

这是一个解决方法,感谢 RomeroMsk 的帮助。

CSS:

.datepicker-years .picker-switch {
cursor: default !important;
background: inherit !important;
}
Run Code Online (Sandbox Code Playgroud)

JS:

$('#datetimepicker1').datetimepicker({
// your datetimepicker options go here, f.i.:
        inline: true,
        sideBySide: false,
        format : "DD/MMM/YYYY",
        maxDate : moment()
}).on('dp.show dp.update', function () {
$(".datepicker-years .picker-switch").removeAttr('title')
    //.css('cursor', 'default')  <-- this is not needed if the CSS above is used
    //.css('background', 'inherit')  <-- this is not needed if the CSS above is used
    .on('click', function (e) {
        e.stopPropagation();
    });
});
Run Code Online (Sandbox Code Playgroud)