Hi I started using Dhtmlx scheduler and it is really cool. I am checking for empty event name or event name already saved in a scheduler object. I am throwing alert based on this check and for the first time it is good. When i close the scheduler and try to add events with same name, the alert is shown multiple times. On tracking the issue, i noticed that "scheduler.attachEvent("onEventSave")" is getting fired multiple times and hence the alert is shown multiple times. How to stop this multiple occurrences on saving a single event.
My code:
scheduler.attachEvent("onEventSave",function(id, ev, is_new){
var event_name_array = [];
var events_JSON_Array = JSON.parse(scheduler.toJSON());
for(var i = 0; i < events_JSON_Array.length; i++)
{
var event = events_JSON_Array[i];
event_name_array.push(scheduler.getEvent(event.id).text);
}
if (!ev.text || (event_name_array.indexOf(ev.text) > -1) && (event_name_array.length > 1)) {
alert('Bad input');
return false;
}
return true;
})
Thanks in advance!!!