1

我可以在日期选择器中逐年返回。但是当我试图回到日期时,当我点击年份时,日期选择器会自动隐藏。

 var datePickerOptions = this.data || {}; 
    datePickerOptions.format = datePickerOptions.format || "mm-dd-yyyy";
    datePickerOptions.language = datePickerOptions.language || this.lang.code; 
    var $context = this;
    var dateContainer = this.container.find(".datepicker");
    dateContainer.datepicker(datePickerOptions).on('changeDate', function (ev) { 
    // here i'm getting the value 
    }); 
4

1 回答 1

0
This because of bootstrap-datepicker.js .
on click event you can find like following.

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();
                        }

而不是this.fill(),如果您使用以下代码,这将按您的预期工作。

if (target.is('.month')) {


     if (!this._o.changeMonth) {
                                        this.fill();
                                    }
                                }
                                else {
                                    if (!this._o.changeYear) {
                                        this.fill();
                                    }
                                }

我希望这能帮到您。:-)

于 2013-11-14T11:08:25.997 回答