使用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*/
});如果我取消对所选日期部分的注释,一旦它加载,我就会在日历上得不到定义,或者它由于语法问题而无法加载
有人能帮上忙吗?
谢谢
发布于 2013-05-16 01:14:16
我也遇到了同样的问题,并从这位德国人的帖子(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-03-16 01:09:50
取消注释所选日期部分时,是否在cellColorScheme:"beige"末尾添加了,?如果不是,你会得到一个语法错误。
发布于 2016-04-13 01:42:04
我也遇到了同样的问题,我的问题是在一个编辑页面上,所以我需要设置在jsDatePick date中编辑的记录,并让它出现在目标文本框中(我不能只在textbox中设置日期,这首先会导致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() {};
}
};https://stackoverflow.com/questions/15437091
复制相似问题