Javascript 无法从旧的jscalendar干净地升级到新的jscal2版本
我为什么需要升级Javascript 无法从旧的jscalendar干净地升级到新的jscal2版本,javascript,configuration,jscalendar,Javascript,Configuration,Jscalendar,我为什么需要升级 我需要具有禁用导航到某个日期之后的日期的功能,因此我正在考虑从jscalendar升级(http://www.dynarch.com/projects/calendar/old/)到jscal2(http://www.dynarch.com/projects/calendar/)在我的项目中。但在新jscal2的主页和文档中,提到了以下内容: 请注意,这是一个全新的产品 请注意,它与我们的旧日历项目不兼容 问题 所以,我很困惑,如果在我当前的项目中有一个最小的变化升级是可能
我需要具有禁用导航到某个日期之后的日期的功能,因此我正在考虑从jscalendar升级(http://www.dynarch.com/projects/calendar/old/)到jscal2(http://www.dynarch.com/projects/calendar/)在我的项目中。但在新jscal2的主页和文档中,提到了以下内容:
- 请注意,这是一个全新的产品
- 请注意,它与我们的旧日历项目不兼容
所以,我很困惑,如果在我当前的项目中有一个最小的变化升级是可能的,如果是这样的话,如何确切地做到这一点。我已经在网站上发表了一条评论,正在等待回复。同时,我认为那些使用过该产品的人可能会有所帮助,所以我的问题是 我的项目的现有代码使用jscalendar版本1.51(我看到calendar.js文件-calendar.js,v1.51中写了这一行)。这些帮助程序代码有几行,其中包含调用
var cal=new Calendar()
的函数showCalendar(),如下所示-
function setActiveStyleSheet()
function selected()
function closeHandler()
function showCalendar(){
...
//some lines of code
...
var cal = new Calendar(1, null, selected, closeHandler);
...
//some lines of code
...
}
....
onSelect: function() {
var date = Calendar.intToDate(this.selection.get());
LEFT_CAL.args.min = date; // setting minimum date, so as to not allow browsing past this date
LEFT_CAL.redraw();
this.hide();
}
function showCalendar(){
...
//some lines of code
...
var cal = new Calendar();
...
//some code to display the calendar, based on the details already being passed to this function - which button was clicked, where to attach the calendar, etc.
...
}
在这里检查相同的
但是我在今天下载的新版本的演示中没有看到那个助手脚本。我试图删除旧版本的所有js/css文件,包括新版本的文件,但只保留相同的jscalendar.js,但它会产生这个js错误-
_dynarch_popupCalendar is not defined
[Break On This Error] if (_dynarch_popupCalendar != null) {
我猜,我可以通过将onSelect
参数添加到新的日历启动中来限制过去的日期,如下所示-
function setActiveStyleSheet()
function selected()
function closeHandler()
function showCalendar(){
...
//some lines of code
...
var cal = new Calendar(1, null, selected, closeHandler);
...
//some lines of code
...
}
....
onSelect: function() {
var date = Calendar.intToDate(this.selection.get());
LEFT_CAL.args.min = date; // setting minimum date, so as to not allow browsing past this date
LEFT_CAL.redraw();
this.hide();
}
function showCalendar(){
...
//some lines of code
...
var cal = new Calendar();
...
//some code to display the calendar, based on the details already being passed to this function - which button was clicked, where to attach the calendar, etc.
...
}
但是在助手脚本中修改失败后,我没有尝试任何操作
请让我知道,如果你有正确的升级过程的想法。我不确定我错过了什么
我原以为这会像更改js的包含一样简单,可能是css文件,代码中不需要任何更改。我只需要设置一些与禁用日期相对应的配置参数
更新现在让它更简单 首先是更正,这不是升级,因为jscal2的文档(我想使用的文档)说-
- 请注意,这是一个全新的产品
- 请注意,它与我们的旧日历项目不兼容
Calendar.setup({
cont : "calendar-container" // a cont or a trigger
});
所有参数都是可选的。但是,您应该提供一个cont
(对于内联日历)或弹出日历的触发器,或提供
您自己的代码显示弹出式日历。我们来看看这是怎么回事
以后再做
我想我需要编写代码来显示弹出式日历,如下所示-
function setActiveStyleSheet()
function selected()
function closeHandler()
function showCalendar(){
...
//some lines of code
...
var cal = new Calendar(1, null, selected, closeHandler);
...
//some lines of code
...
}
....
onSelect: function() {
var date = Calendar.intToDate(this.selection.get());
LEFT_CAL.args.min = date; // setting minimum date, so as to not allow browsing past this date
LEFT_CAL.redraw();
this.hide();
}
function showCalendar(){
...
//some lines of code
...
var cal = new Calendar();
...
//some code to display the calendar, based on the details already being passed to this function - which button was clicked, where to attach the calendar, etc.
...
}
但是,我在文档中没有看到任何这样的代码。我尝试使用此代码,但不起作用-
function trigger()
{
cal = new Calendar({
inputField: "startdate",
dateFormat: "%B %d, %Y",
bottomBar: false,
showTime:true
}
});
cal.redraw(); //blind try - does not work, but it does not give any errors. But I
don't see any other proper function to do this in the doc.
}
有什么想法吗,伙计们
谢谢
赏金开始找到了一个不太好的、未优化的解决方案,在回答中发布,但仍在寻找合适的解决方案。回答自己的问题,但仍在寻找合适的解决方案。我编写这段代码是为了在从jscalendar移动到jsCal2之后继续使用
showCalendar()
函数-
var instance = null; //tracker of calendar instances
function showCalendar(id, format, showsTime, showsOtherMonths)
{
//some code here
//create a dummy holder so as to place the calendar inside, so that I can use the "cont" attribute. (Have to use either cont or trigger. )
if(instance!=null)
{
instance.hide();
instance = null;
$("table.DynarchCalendar-topCont").remove(); //I am having to kill the earlier calendar instance on every calendar display call, because otherwise multiple instances were getting created in DOM, causing confusion.
//get date in input field - since earlier instance is killed
}
if($("div#container").length == 0)
{
$('body').append('<div id="container" style="position: absolute;"> </div>');
}
cal = new Calendar({
cont: "container",
inputField: id,
dateFormat: format,
bottomBar: false,
min: minDateLimit,
showTime: showsTime,
weekNumbers: true,
selection : intDate,
onSelect: function() {
//set selected value into attached input field
var selectedDate = this.selection.get();
date = Calendar.intToDate(selectedDate);
date = Calendar.printDate(date, format);
$('#'+id).val(date);
this.hide();
},
onBlur: function() { //clicking outside hide calendar
this.hide();
}
});
cal.moveTo(intDate); //since new instance of calendar is being created everytime, need to move to the date
cal.popup(id,"Br");
instance = cal;
return false;
}
var实例=null//日历实例的跟踪器
功能showCalendar(id、格式、showsTime、ShowSoThermons)
{
//这里有一些代码
//创建一个虚拟支架,以便将日历放在里面,这样我就可以使用“cont”属性。(必须使用cont或trigger。)
if(实例!=null)
{
instance.hide();
实例=null;
$($table.DynarchCalendar topCont”).remove();//我必须在每次日历显示调用中终止较早的日历实例,因为在DOM中创建了多个实例,这会造成混乱。
//在输入字段中获取日期-因为较早的实例已被终止
}
if($(“div#container”).length==0)
{
$('body')。追加('');
}
cal=新日历({
续:“集装箱”,
输入字段:id,
日期格式:格式,
底线:错,
敏:明达利米特,
showTime:showTime,
周数:对,
选择:intDate,
onSelect:function(){
//将选定值设置到附加的输入字段中
var selectedDate=this.selection.get();
日期=日历.intToDate(selectedDate);
日期=日历。打印日期(日期,格式);
$('#'+id).val(日期);
this.hide();
},
onBlur:function(){//单击外部隐藏日历
this.hide();
}
});
cal.moveTo(intDate);//由于每次都会创建新的日历实例,因此需要移动到该日期
校准弹出窗口(id,“Br”);
实例=cal;
返回false;
}
为了从内联onclick函数(这里的showcalendar()函数)中启动弹出式日历,我尝试了很多方法。但是,在新jscal2 calendar的文档中,calendar的启动只支持绑定方法,而无法从内联onclick调用的函数内部执行相同的操作。以下是文档-(检查触发器
和cont
参数,其中一个是必需的)。
我应用了一些脏补丁来做同样的事情,结果不得不编写代码来做一些插件自动完成的事情(例如,在输入字段上显示选定日期=日期,在日历显示上)