2
$('.custom_datepicker_selector').datepicker({
dateFormat: 'dd/mm/yy'
}).on('changeDate', function(en) {

  alert("HI");
});

目前我正在使用 bootstrap-datepicker.js。

即使在我将日期选择器选项设置为之后,日期选择器小部件也会自动隐藏月份和年份选择

datePickerOptions.changeMonth = true;
datePickerOptions.changeYear = true;

我只想在日期选择上隐藏日期选择器,而不是在月份和年份选择上。怎么做 ?

4

1 回答 1

1
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() ,那么它会按预期工作。

于 2013-11-01T07:55:12.717 回答