首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >jsDatePick -使用选定的日期

jsDatePick -使用选定的日期
EN

Stack Overflow用户
提问于 2013-03-16 00:09:42
回答 3查看 3.9K关注 0票数 0

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

完整的代码可以从JsDatePick下载

他们提供的代码

代码语言:javascript
复制
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*/
});

如果我取消对所选日期部分的注释,一旦它加载,我就会在日历上得不到定义,或者它由于语法问题而无法加载

有人能帮上忙吗?

谢谢

EN

回答 3

Stack Overflow用户

发布于 2013-05-16 01:14:16

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

代码语言:javascript
复制
 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“。

希望这能有所帮助。

票数 1
EN

Stack Overflow用户

发布于 2013-03-16 01:09:50

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

票数 0
EN

Stack Overflow用户

发布于 2016-04-13 01:42:04

我也遇到了同样的问题,我的问题是在一个编辑页面上,所以我需要设置在jsDatePick date中编辑的记录,并让它出现在目标文本框中(我不能只在textbox中设置日期,这首先会导致NaN问题)。所以我的解决方案是塞萨尔的方案的扩展:

代码语言:javascript
复制
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函数出现问题,需要将其更改为:

代码语言:javascript
复制
JsDatePick.prototype.closeCalendar = function () {
    if (this.JsDatePickBox) {
        this.JsDatePickBox.style.display = "none";
        document.onclick = function() {};
    }
};
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/15437091

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档