0

使用 jsDatePick Full JQuery 示例,我无法使用选定的指定日期加载日历,我收到未定义的消息或语法错误

完整代码可以从JsDatePick下载

他们提供的代码

g_globalObject2 = new JsDatePick({
useMode:1,
isStripped:false,
target:"div4_example",
cellColorScheme:"beige"
/*          
selectedDate:{
day:16,
month:3,
year:2013
},
yearsRange:[1978,2020],
limitToToday:false,
dateFormat:"%m-%d-%Y",
imgPath:"img/",
weekStartDay:1*/
});

如果我然后取消评论选定的日期部分,我会在加载后在日历上未定义,或者由于语法问题而无法加载

任何人都可以帮忙吗?

谢谢

4

3 回答 3

1

我遇到了同样的问题,并从这个德国人(http://www.viathinksoft.de/?page=news&id=184)的帖子中找到了以下解决方案。这篇文章是德文的,如果你翻译成英文,它会弄乱他提供的代码,所以先复制代码,或者你可以在下面复制。这是他的修复,你需要修改“jsDatePick.full.1.3.js”脚本,函数“setConfiguration”如下:

 this.selectedDayObject = {};
 this.flag_DayMarkedBeforeRepopulation = false;
 this.flag_aDayWasSelected = false;
 this.lastMarkedDayObject = null;

 if (!this.oConfiguration.selectedDate){
      this.currentYear      = this.oCurrentDay.year;
      this.currentMonth     = this.oCurrentDay.month;
      this.currentDay          = this.oCurrentDay.day;
 } else {
      this.currentYear      = this.oConfiguration.selectedDate.year;
      this.currentMonth     = this.oConfiguration.selectedDate.month;
      this.currentDay          = this.oConfiguration.selectedDate.day;
      this.selectedDayObject = this.oConfiguration.selectedDate;
      this.flag_aDayWasSelected = true;                                   
 }

基本上,他在代码中添加了“else”条件和操作。

在您的 HTML 中,您需要使用“jsDatePick.full.1.3.js”。

希望这可以帮助。

于 2013-05-15T17:14:16.270 回答
0

取消注释所选日期部分时,您是否,在末尾添加了一个cellColorScheme:"beige"?如果不是,您将收到语法错误。

于 2013-03-15T17:09:50.130 回答
0

我遇到了同样的问题,我的在编辑页面上,所以我需要在 jsDatePick 日期中设置正在编辑的记录,并将其显示在目标文本框中(我不能只在文本框中设置日期,这导致首先是NaN问题)。所以我的决议是塞萨尔的一个延伸:

this.selectedDayObject = {};  
this.flag_DayMarkedBeforeRepopulation = false;  
this.flag_aDayWasSelected = false;  
this.lastMarkedDayObject = null;


 if (!this.oConfiguration.selectedDate){
      this.currentYear      = this.oCurrentDay.year;
      this.currentMonth     = this.oCurrentDay.month;
      this.currentDay          = this.oCurrentDay.day;  } else {
      this.currentYear      = this.oConfiguration.selectedDate.year;
      this.currentMonth     = this.oConfiguration.selectedDate.month;
      this.currentDay          = this.oConfiguration.selectedDate.day;
      this.selectedDayObject = this.oConfiguration.selectedDate;
      this.flag_aDayWasSelected = true; 
      this.populateFieldWithSelectedDate();
}

这会导致 closeCalendar 函数出现问题,需要将其更改为:

JsDatePick.prototype.closeCalendar = function () {
    if (this.JsDatePickBox) {
        this.JsDatePickBox.style.display = "none";
        document.onclick = function() {};
    }
};
于 2016-04-12T17:42:03.787 回答