Reinitialize DHTMLX Scheduler

Hey guys,

I need to reinitalize the scheduler via JavaScript. In my case, I’ve got a scheduler in a page. By clicking on a button the same schedular with different Data/Events/Stuff should be rendered (no page relaod). So, while scheduler is a global JavaScript object (urgggs, bad pattern), all Events/States are binded in this global object. So every event/state is passed to the new schedular, which is very very bad. All events binded before, are triggered too.

scheduler.attachEvent("onDblClick", function(eventId){ console.log('Only once'); });

Any Ideas how to handle this?

Hello,
currently scheduler do not have a destructor, so there are two approaches for reinitializing scheduler with event handlers

  1. make sure that events are attached only once when you initialize the scheduler for the first time
  2. detach old events before initializing the scheduler. Here is how it can be done -
    scheduler.attachEvent returns id of the event handler, which can be used to detach event later
    docs.dhtmlx.com/scheduler/api__s … event.html
    docs.dhtmlx.com/scheduler/api__s … event.html
    So using these two methods are desired approach for work with event handlers.

detachAllEvents should be avoided, we’re going to mark it as obsolete and remove from the public api (although it’s quite not expected that it throws an error).

Thx, thats the same approach I tried. I created a Plunker included an AngularJS application for everbody who runs into that. http://plnkr.co/edit/wCO7xYH0dEUHSxtH6cHE?p=preview. Its works like a charm.

Unfortunately this solution doesnt work in my current project. I will update this thread, once I found the problem.