Open MrZhangFengfeng opened 7 years ago
In Chinese
当minDate的参数为2017/08/01时,在UIDateTimePicker控件,先依据年份查一个日期:如2022/01/20。
然后选择了而一个后面的日期,但是又不想要这个日期了,想选前面的minDate所在年份的日期。
再使用年份查找到2017/07/12的时候。就无法选择2017年的年份。必需先选择2018,然后再回退到2017年。
我刚刚也遇到这个问题了,查看源码,找到原因,这是一个小bug
压缩版的 min.js:
把 this.onRenderYear=function(o){ ......... } 中的
if(o<this.startDate || n>r ){
p.push("disabled")
}
修改为 :
if(o.getUTCFullYear()<this.startDate.getUTCFullYear() || n>r){
p.push("disabled")
}
就可以了。
未压缩的js:
this.onRenderYear = function (date) {
var render = (options.onRenderYear || function () { return []; })(date);
var res = ['year'];
if (typeof render === 'string') {
render = [render];
}
if (this.date.getUTCFullYear() === date.getUTCFullYear()) {
res.push('active');
}
var currentYear = date.getUTCFullYear();
var endYear = this.endDate.getUTCFullYear();
if (date < this.startDate || currentYear > endYear) {
res.push('disabled');
}
return res.concat((render ? render : []));
}
修改为:
this.onRenderYear = function (date) {
var render = (options.onRenderYear || function () { return []; })(date);
var res = ['year'];
if (typeof render === 'string') {
render = [render];
}
if (this.date.getUTCFullYear() === date.getUTCFullYear()) {
res.push('active');
}
var currentYear = date.getUTCFullYear();
var startYear = this.startDate.getUTCFullYear();
var endYear = this.endDate.getUTCFullYear();
if (currentYear < startYear || currentYear > endYear) {
res.push('disabled');
}
return res.concat((render ? render : []));
}
即可!
While setting a minDate(2017/09/07),then click the year to choose a date latter than minDate.
Then,I don‘t want this date. I click the year to get back.
But now,I can't choose the minDate's year.(2017) I have to choose 2018 then back to 2017.