$('.custom_datepicker_selector').datepicker({
dateFormat: 'dd/mm/yy'
}).on('changeDate', function(en) {
alert("HI");
});
目前我正在使用 bootstrap-datepicker.js。
即使我将日期选择器选项设置为,日期选择器小部件也会自动隐藏月份和年份选择
datePickerOptions.changeMonth = true;
datePickerOptions.changeYear = true;
我只想在选择日期时隐藏日期选择器,而不是在选择月份和年份时隐藏日期选择器。如何做到这一点?
最佳答案
case 'span':
if (!target.is('.disabled')) {
this.viewDate.setUTCDate(1);
if (target.is('.month')) {
var day = 1;
var month = target.parent().find('span').index(target);
var year = this.viewDate.getUTCFullYear();
this.viewDate.setUTCMonth(month);
this._trigger('changeMonth', this.viewDate);
if (this.o.minViewMode === 1) {
this._setDate(UTCDate(year, month, day,0,0,0,0));
}
} else {
var year = parseInt(target.text(), 10)||0;
var day = 1;
var month = 0;
this.viewDate.setUTCFullYear(year);
this._trigger('changeYear', this.viewDate);
if (this.o.minViewMode === 2) {
this._setDate(UTCDate(year, month, day,0,0,0,0));
}
}
this.showMode(-1);
this.fill(); // when execute this function, datepicker widget is hide;
如果我们注释 this.fill() 或者如果我们根据changeYear、changeMonth条件调用这个this.fill(),那么它会按照我们的预期工作。
关于jquery - 日期选择器小部件隐藏月/年选择,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19706049/