English 中文(简体)
无法从旧的jplndar升至新的jscal2版本
原标题:Unable to cleanly upgrade from old jscalendar to new jscal2 version

Why I need to upgrade
I need to have the feature of disabling of navigating to dates past some date, so I am considering upgrading from jscalendar (http://www.dynarch.com/projects/calendar/old/) to jscal2 (http://www.dynarch.com/projects/calendar/) in my project. But in homepage and documentation of the new jscal2, following things are mentioned -

  • 请注意,这是一个全新的产品。

  • 请注意,这不符合我们原来的日历项目。

Problem
So, I am confused, if an upgrade with minimal changes in my current project is possible and if so how exactly to do that. I have already posted a comment in the site - http://www.dynarch.com/projects/calendar/discussion/ and waiting for some reply. In the meantime, I thought those who have used the product might be able to help, so here is my question.

我现有项目代码使用jpanndar版本 1.51(见日历.js,v 1.51)。 这些助手代码有几行,其中包括<代码>功能显示Calendar(,其中var cal = 新的日历()。

function setActiveStyleSheet()
function selected()
function closeHandler()
function showCalendar(){
    ...
    //some lines of code
    ... 
    var cal = new Calendar(1, null, selected, closeHandler);
    ...
    //some lines of code
    ... 
}
....

www.un.org/chinese/ga/president

但我看不到今天我下载的新版本的mos。 我试图删除旧版本的所有js/cs档案,包括新版本的档案,但只保留同样的jplndar.js,但造成这种错误——

_dynarch_popupCalendar is not defined
[Break On This Error] if (_dynarch_popupCalendar != null) { 

我猜测,我可以把<代码>onSelect param添加到新的日历开始之时,从而限制过去的日期。

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();
}

But I did not try anything after modifying in the helper script failed.

Please let me know if you have idea about the correct upgrading process. I am not sure what I am missing something.

I had thought it would be as simple as just changing inclusion of the js and may be css files and no change would be needed in code. I would just need to set some more config parameters corresponding to disabling the dates as I desire.

Update
Making it simpler now!!

首先,这并不是一种升级,因为jscal2(我想要使用)的剂量表示:

  • 请注意,这是一个全新的产品。

  • 请注意,这不符合我们原来的日历项目。

I understood that the minimum needed to invoke a calendar is -

Calendar.setup({
    cont          : "calendar-container"  // a cont or a trigger
});

All arguments are optional. However, you should provide one of cont (for inline calendars) or trigger for popup calendars, or else provide your own code to display a popup calendar. We ll see how this can be done later.

我认为,我需要写这部法典,以显示像现在这样一幅人口日历:

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.  
}

任何想法?

增 编

Bounty Started
Have found a not-so-good, unoptimized solution, posted it in answer, but still looking for a proper solution.

最佳回答

回答自己,但仍寻求适当的解决办法。 我写过这部法律,在从jpanndar移至jsCal2之后,继续使用howCalendar()功能。

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;">&nbsp;</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;
}

I tried a lot for some proper way to initiate a popup calendar from inside an inline onclick function (showcalendar() function here). But, in the documentation of new jscal2 calendar, the initiation of calendar supports only binding method, and no way to do the same from inside a function which is called from an inline onclick. Here is the documentation - http://www.dynarch.com/projects/calendar/doc/ (check the trigger and cont parameters, one of which is mandatory). I applied some dirty fix to do the same and as a result had to write code to do some things which are otherwise automatically done by the plugin (e.g. display of selected date = date on input field, on display of calendar).

问题回答

暂无回答




相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签