DHTMLX / scheduler

GPL version of JavaScript Event Scheduler
https://dhtmlx.com/docs/products/dhtmlxScheduler/
GNU General Public License v2.0
311 stars 110 forks source link

How to reinit scheduler #47

Open akvaliya opened 4 years ago

akvaliya commented 4 years ago

What is the best way to reinitialize scheduler.

I have app which supports multi-language. When language localization data doesn't apply to light-box action buttons until scheduler's init method called again.

If i do that then in mobile devices on double tap with details_on_create, it created multiple entries. Like if scheduler is initialize twice then it creates double entries on double tap.

scheduler.skin = "material";
scheduler.config.responsive_lightbox = true;
scheduler.config.touch = true;
scheduler.config.first_hour = 4;
scheduler.config.details_on_create = true;
scheduler.config.lightbox.sections = [
    { name: "description", height: 43, map_to: "text", type: "textarea", focus: true },
    { name: "time", height: 72, type: "time", map_to: "auto" }
];
this.translationToolsData.currentTransToolsObj.subscribe(translationObj => {
    this.translationObj = translationObj;
    if (this.translationObj) {
        scheduler.locale = {
          labels: {
                dhx_cal_today_button: this.translationObj.dhx_cal_today_button,
                day_tab:this.translationObj.schedulerday,
                week_tab:this.translationObj.schedulerweek
             }
        }
        scheduler.init(this.schedulerContainer.nativeElement, new Date(), "week");
        scheduler.setCurrentView();
    }
}); 

segemun commented 4 years ago

You should reset event listeners on the scheduler container before new initialization. Something like that: $('#scheduler-container').replaceWith($('#scheduler-container').clone()); scheduler.init(...)