Hi,
currently, there is no destructor, scheduler works as a static object.
In your case, you can workaround this by reusing a single instance of scheduler.
You can store the instance of scheduler after you hide calendar. And when you need to show it again you initialize the same instance in the new container, rather than creating a new instance of scheduler.
scheduler.init("newContainerId");
scheduler.init can be called multiple times. Please note that initialization does not clear previously attached event handlers (e.g. scheduler.attachEvent(“onViewChange”, function(){/do something/}) ) and templates, so if you define event handlers upon scheduler initialization - you’ll need to make sure they attached only once.
Is there any “destroy scheduler” method in roadmap for free or pro version?
We’ll possibly add it in the next major update, but it’s not for sure. In most use cases scheduler instance is supposed to live as long as page lives, so the lack of destructor wasn’t a priority issue.
Hi,
can you please show some code, so we could better understand the issue?
Most probably you initialize scheduler each time window is opened, and as a part of this initialization, you attach event listeners, dataProcessor, etc.
As a solution, make sure to perform a complete initialization only once when scheduler window is shown for the first time and all the next times call only scheduler.init/scheduler.clearAll/scheduler.load without reapplying event listeners and a data processor
So i’ve got a Vue SPA with multi pages. One page is using a scheduler.
So the first time i open this page, i create the instance (‘scheduler.createTimelineView’, event loaders, lightbox customisation,…).
If i change to another page and then i go back to the scheduler page, my application knows that there is already an instance of scheduler so it just do this line “scheduler.init(“scheduler_here”,new Date(),“timeline”);”. So that means that i still have an instance of Scheduler.
BUT, i think the event loaders are created every time i go to the scheduler page. So that means that if i go 4 times in this page, each event loader is created 4 times as well. That’s why i get 4 confirmation messages.
It may be because of Vue.JS. I’m using components to display my pages. The scheduler page is a component.
I tried to destroy the container after i leave the page (inside the beforeRouteLeave() function). Then when i go back to the scheduler page, i destroy again the container and create a new one just before i call the init call.
But unfortunately it still calls twice or more the confirmation message.
So this confirmation message i declare them inside the scheduler.attachEvent(‘onBeforeEventChanged’) function. And it is only called the first time i enter in the scheduler page. The other times i don’t call this function. Don’t know if it helps you.
i tried the destructor but it doesn’t work. we needed this in our angular application and we place it in ngOnDestroy but still no luck… the documentation about it is very minimal, i wish you guys have better content writer to document things properly per technology as waiting for support’s replay is not ideal due to time constrains. I also have connected with you guys via email and there is no response for weeks now from one of your team “Sergey”. We thought we will get better support due to we have a purchase license.
Get a guaranteed answer from DHTMLX technical support team
under the most suitable support plan