What is the best way to prevent dhtmlxscheduler lightbox from creating multiple events when you hit save multiple times in a row. I found this happened on accident but it’s very easy to create by double clicking save as fast as you can. I’m using DataProcessor and it will be called multiple times to create new events.
Hello @keiths1 ,
I tried to reproduce it in our official samples:
https://docs.dhtmlx.com/scheduler/samples/01_initialization_loading/05_loading_database.html
But the issue isn’t seems to occur, could you please check if the issue occurs in the demo above?
As a workaround, you can use some flag in the onEventSave
and return true
only if flag is true
. The logic could be set this flag to false
from this event, and set it back from some timeout(for example 1sec) - what should be enough for the lightbox to be closed with no additional saves.
Te code may look like follows:
let saveFlag = true;
scheduler.attachEvent("onEventSave",function(id,ev,is_new){
if(saveFlag){
saveFlag = false;
setTimeout(() => {
saveFlag = true;
}, 1000)
return true;
} else {
return false;
}
})
Here is example:
https://snippet.dhtmlx.com/8d9shwv8
Kind regards,