dhtmlxscheduler lightbox fails if page is re-loaded

We are running into a problem if the page containing dhtmlxscheduler v3.0 is re-loaded. If the user attempts to create a new event, the scheduler recalls the last event that was created or edited. It then fails to cancel, save or delete. This only happens if the page is reloaded and only if the user has invoked lightbox when the page was first loaded. Are there any special cleanup APIs that must be called when the dhtmlxscheduler is destroyed or when it is reloaded?

Upon creating a new event with lightbox, the following error is shown in the console:
document.getElementById(e[f].id) is null
…te,c.end_date,c)):(d[1].innerHTML=this.templates.event_header(c.start_date,c.end…
dhtmlx…uler.js (line 177)

Pressing cancel produces:
a is undefined
…nt=null):b&&this.callEvent(“onEventChanged”,[a.id,a])};scheduler.getEvents=funct…
dhtmlx…uler.js (line 154)

Pressing save produces:
a is null
…nction(a){return a.innerHTML||""},focus:function(){}},textarea:{render:function(…
dhtmlx…uler.js (line 167)

Pressing delete produces:
c is undefined
…)[b]:this._userdata[b]};scheduler.setEventTextStyle=function(a,b){this.for_rende…
dhtmlx…uler.js (line 194)

We are using connector for persistence; however the log file does not show any errors. Here is the tail of SchedulerConnector.log:

Log started, Tue May 22 15:03:16 EDT 2012

CScheduler.configure(): created SchedulerConnector c
CScheduler.configure(): before c.render_table()
DB query
SELECT eID,eStart,eEnd,eDescription,eNotes,oID,pID,dID,eStatus FROM tblevents

Done in : 11ms

====================================
Log started, Tue May 22 15:03:31 EDT 2012

CScheduler.configure(): created SchedulerConnector c
CScheduler.configure(): before c.render_table()
DB query
UPDATE tblevents SET eStart=‘2012-05-22 07:00’,eEnd=‘2012-05-22 08:30’,eDescription=‘budget review’,eNotes=‘Sales budget review weekly meeting’,oID=‘5’,pID=‘6’,dID=‘6’,eStatus=‘Confirmed’ WHERE eID=‘30’

Done in : 2ms

====================================
Log started, Tue May 22 15:04:30 EDT 2012

CScheduler.configure(): created SchedulerConnector c
CScheduler.configure(): before c.render_table()
DB query
SELECT eID,eStart,eEnd,eDescription,eNotes,oID,pID,dID,eStatus FROM tblevents

Done in : 3ms

Hello,

Please provide link where we could check this issue.

Kind regards,
Ilya

Hi Ilya,

Thanks for your reply.

My application is not accessible from a public URL. I can work on getting the scheduler part out by itself. I’ll see if I can do that. In the meantime, I have attached my HTML and java script code where the scheduler is used. Please use key “mysched” to view the files. I highlighted the configuration and initialization sections below:
[b] scheduler.init(‘scheduler_here’, null, “unit”);
scheduler.load(“/myapp/scheduler/eventsx.do?uid=” + scheduler.uid());

[/b] myDP = new dataProcessor(“/myapp/scheduler/eventsx.do”);
myDP.init(scheduler);
scheduler.attachEvent(“onEventChanged”, function(event_id, event_object)
{
// …
myLocalDP.setUpdated(event_id, true);
});

Thanks for your help,
msamarah
mysched.zip (1.31 KB)

Hello,

How come reloading calendar (and that’s the same as second load) is any different to the first one? Do you store and use some variables?
I mean then you load some page you get clean state, if you reload it - once again you have clean state. I am not sure how something can go wrong when you reload (load once again) same page.

Kind regards,
Ilya

Hi Ilya,

I have a handler attached for OnEventChanged. It uses an application level variable to get at the data processor. Do I need this handler? And if so how do I avoid using a state variable? Or is there a way to detach the handler? The code is shown below:

        scheduler.attachEvent("onEventChanged", function(event_id, event_object) {
            var myLocalDP = app.varInfo.getValue("DataProcessor");
            myLocalDP.setUpdated(event_id, true);
        });

Many thanks for your help.
msamarah

Hello,

Can we please clarify steps to reproduce this issue please.

  1. Load scheduler page
  2. Open lightbox of any event
  3. Press F5 (page is refreshed)

And at this point you get script error?

Kind regards,
Ilya

Hi Ilya,

The steps are:

  1. Load scheduler page
  2. Open lightbox, press cancel
  3. Reload scheduler page
  4. Open lightbox, press cancel. Now fails to dismiss light box and produces script errors as stated in the first post:

Opening the lightbox produces:
document.getElementById(e[f].id) is null
…te,c.end_date,c)):(d[1].innerHTML=this.templates.event_header(c.start_date,c.end…
dhtmlx…uler.js (line 177)

Pressing cancel produces:
a is undefined
…nt=null):b&&this.callEvent(“onEventChanged”,[a.id,a])};scheduler.getEvents=funct…
dhtmlx…uler.js (line 154)

Pressing save produces:
a is null
…nction(a){return a.innerHTML||""},focus:function(){}},textarea:{render:function(…
dhtmlx…uler.js (line 167)

Pressing delete produces:
c is undefined
…)[b]:this._userdata[b]};scheduler.setEventTextStyle=function(a,b){this.for_rende…
dhtmlx…uler.js (line 194)

Thanks for your help.
msamarah

Hello,

Can’t tell with only that code. If at some point your application can be accessible - please share link so we could look what’s wrong.
Also try commenting out parts of code, maybe you will find what causing this issue.

Another note:
myLocalDP.setUpdated(event_id, true);

I don’t see myLocalDP defined, only used.

Kind regards,
Ilya

Hi Ilya,

Sorry for the late response. I missed the notification for your last update. I was able to make it work by simply loading the page only once and never re-loading it again until the application is terminated. In doing so, I am invoking the scheduler.init and scheduler.load APIs only once. It seems that the problem I ran into had to do with loading multiple instances of the scheduler object, since in some cases I was getting as many events created as the number of times the scheduler page was loaded. All is well now.

Many thanks for your help,
msamarah

The following command resets light box:

scheduler.resetLightbox();

This statement can resolve the issue.