Getting TypeError: elem is undefined error in the Firebug

Hi,
I am getting “TypeError: elem is undefined” error in the Firebug as soon as I click inside my dhtmlxCalendar field in dhtmlxscheduler custom lightbox. Please see picture for more details. Moreover, I have following questions :

[b]How can I check for a new event or an old event and where should this code go(which event handler)?

How can I restrict users from creating more than 1 event per day? [/b]

scheduler.locale.labels.timeline_tab = "Timeline" //This is for a timeline_tab			
scheduler.locale.labels.section_Assessor = "Assessor"; // This is a section  in a lightbox
				
scheduler.config.details_on_create = true;
scheduler.config.details_on_dblclick = true;
scheduler.config.drag_move = false;
scheduler.config.show_loading = true;
scheduler.config.xml_date = "%Y-%m-%d %H:%i";  
scheduler.config.start_on_monday = true;
											
scheduler.createTimelineView({
	name: "TopTimeline",
	x_unit:	"day",
	x_date:	"%D, %d %M %y ",
	x_step:	1,
	x_size: 7,			
	y_unit:	AssessorsArray,
	y_property:"UserID",
	render:"bar"
});	 			

scheduler.form_blocks["my_editor"]={
	render:function(sns){
		return "<div class='dhx_cal_ltext' style='height:750px;'> <table width='650px' cellspacing='3'> <tbody> <tr> <td class='LightBoxHeadingCell'> Association : </td> <td> <select name='AssociationDropDown' id='AssociationDropDown' onchange='AssociationDropDownOnChange();'> <option selected = '' value='EvaluatorsOffice'>Evaluators Office</option> <option value='Clinic'>Clinic</option> </select> </td> </tr> <tr id='StatusRow'> <td class='LightBoxHeadingCell'> Status : </td> <td> <select style='width:150px' name='StatusDropDown' id='StatusDropDown'> <option selected = '' value='Available'>Available</option> <option value='UnAvailable'>UnAvailable</option> </select> </td> </tr> <tr id='ReasonRow'> <td class='LightBoxHeadingCell'> Reason : </td> <td> <select style='width:150px' name='ReasonDropDown' id='ReasonDropDown'> <option selected = '' value='PersonalLeave'>Personal Leave</option> <option value='Sick'>Sick</option> <option value='StatHoliday'>Stat Holiday</option> <option value='Sick'>Sick</option> <option value='Training'>Training</option> <option value='Vacation'>Vacation</option> </select> </td> </tr> <tr id='ReserveTypeRow'> <td class='LightBoxHeadingCell'> Reserve Type : </td> <td> <select style='width:150px' id='ReserveTypeDropDown' name='ReserveTypeDropDown'> <option selected = '' value='Regular'>Regular</option> <option value='All Call'>All Call</option> </select> </td> </tr> <tr id='ReservedForRow'> <td class='LightBoxHeadingCell'> Reserved For : </td> <td> <select style='width:150px' id='ReservedForDropDown' name='ReservedForDropDown'> <option selected = '' value='Any'>Any</option> <option value='CAT Only'>CAT Only</option> <option value='In-Person Only'>In-Person Only</option> </select> </td> </tr> <tr id='StartCalendarRow'> <td class='LightBoxHeadingCell' id='StartDateLabel'> Start Date : </td> <td> <input type='text' id='StartDateCalendar1'> </td> </tr> <tr id='EndDatesCalendarRow'> <td class='LightBoxHeadingCell'> End Date : </td> <td> <input type='text' id='EndDateCalendar'> </td> </tr> <tr id='AvailableTimesRow'> <td colspan='2'> <table width='500px' cellspacing='1' style='margin-top: 5px;border: 1px solid black;' id='AvailableTimesTable'> <tbody> <tr> <td colspan='2' class='LightBoxHeadingCell'> Available Times : </td> </tr> <tr> <td class='AvailableTimes'> <input type='checkbox' id='Chk_0800_0830'>08:00 - 08:30 AM </td> <td class='AvailableTimes'> <input type='checkbox' id='Chk_0830_0900'>08:30 - 09:00 AM </td> <td class='AvailableTimes'> <input type='checkbox' id='Chk_0900_0930'>09:00 - 09:30 AM </td> <td class='AvailableTimes'> <input type='checkbox' id='Chk_0930_1000'>09:30 - 10:00 AM </td> </tr> <tr> <td class='AvailableTimes'> <input type='checkbox' id='Chk_1000_1030'>10:00 - 10:30 AM </td> <td class='AvailableTimes'> <input type='checkbox' id='Chk_1030_1100'>10:30 - 11:00 AM </td> <td class='AvailableTimes'> <input type='checkbox' id='Chk_1100_1130'>11:00 - 11:30 AM </td> <td class='AvailableTimes'> <input type='checkbox' id='Chk_1130_1200'>11:30 - 12:00 PM </td> </tr> <tr> <td class='AvailableTimes'> <input type='checkbox' id='Chk_1200_1230'>12:00 - 12:30 PM </td> <td class='AvailableTimes'> <input type='checkbox' id='Chk_1230_0100'>12:30 - 01:00 PM </td> <td class='AvailableTimes'> <input type='checkbox' id='Chk_0100_0130'>01:00 - 01:30 PM </td> <td class='AvailableTimes'> <input type='checkbox' id='Chk_0130_0200'>01:30 - 02:00 PM </td>  </tr> <tr> <td class='AvailableTimes'> <input type='checkbox' id='Chk_0200_0230'>02:00 - 02:30 PM </td> <td class='AvailableTimes'> <input type='checkbox' id='Chk_0230_0300'>02:30 - 03:00 PM </td> <td class='AvailableTimes'> <input type='checkbox' id='Chk_0300_0330'>03:00 - 03:30 PM </td> <td class='AvailableTimes'> <input type='checkbox' id='Chk_0330_0400'>03:30 - 04:00 PM </td>  </tr> <tr> <td class='AvailableTimes'> <input type='checkbox' id='Chk_0400_0430'>04:00 - 04:30 PM </td> <td class='AvailableTimes'> <input type='checkbox' id='Chk_0430_0500'>04:30 - 05:00 PM </td> <td class='AvailableTimes'> <input type='checkbox' id='Chk_0500_0530'>05:00 - 05:30 PM </td> <td class='AvailableTimes'> <input type='checkbox' id='Chk_0530_0600'>05:30 - 06:00 PM </td> <td class='AvailableTimes'> &nbsp; </td> <td class='AvailableTimes'> &nbsp; </td> </tr> </tbody> </table> </td> </tr> <tr id='AssessorNotesRow'> <td valign='top' class='LightBoxHeadingCell'> Assessor Notes : </td> <td> <textarea name='AssessorNotes' style='border: solid 1px #CCC;width:350px;height:70px;font-size: 12px;' id='AssessorNotes'> </textarea> </td> </tr> <tr id='AssessmentsDivRow'> <td colspan='2' class='LightBoxHeadingCell'> <span>Assessments :</span> <div id='AssessmentsGrid' style='margin-top:5px;width:500px;'> </div> </td> </tr> <tr id='NotesRow'> <td valign='top' class='LightBoxHeadingCell'> Notes : </td> <td> <textarea name='Notes' style='border: solid 1px #CCC;width:350px;height:70px;font-size: 12px;' id='Notes'> </textarea> </td> </tr> </tbody> </table> </div>";
	},
	set_value:function(node,value,ev){ 			
		 var myCalendar = new dhtmlXCalendarObject(['StartDateCalendar1','EndDateCalendar']); 
		 myCalendar.hideTime();							 
		 $('#StartDateCalendar1').val(ev.StartDate || "");
		 $('#EndDateCalendar').val(ev.EndDate || "");						
		 $("#ReasonDropDown option:contains(" + ev.Reason + ")").attr('selected', 'selected');					
		 $("#ReserveTypeDropDown option:contains(" + ev.ReserveType + ")").attr('selected', 'selected');
		 $("#ReservedForDropDown option:contains(" + ev.ReservedFor + ")").attr('selected', 'selected');			
		 $('#AssessorNotes').val(ev.AvailabilityNote || "");	
		 $('#Notes').val(ev.BookingNote || "");								
		 $('#AvailableTimesTable input:checkbox').attr('checked','');
		 
		if(ev.AvailableTimes)
		{ 
			if(ev.AvailableTimes.indexOf('08:00 AM - 08:30 AM') > -1)	
				$('#Chk_0800_0830').attr('checked','checked');
				
			if(ev.AvailableTimes.indexOf('08:30 AM - 09:00 AM') > -1)	
				$('#Chk_0830_0900').attr('checked','checked');
				
			if(ev.AvailableTimes.indexOf('09:00 AM - 09:30 AM') > -1)	
				$('#Chk_0900_0930').attr('checked','checked');
				
			if(ev.AvailableTimes.indexOf('09:30 AM - 10:00 AM') > -1)	
				$('#Chk_0930_1000').attr('checked','checked');
				
			if(ev.AvailableTimes.indexOf('10:00 AM - 10:30 AM') > -1)	
				$('#Chk_1000_1030').attr('checked','checked');
				
			if(ev.AvailableTimes.indexOf('10:30 AM - 11:00 AM') > -1)	
				$('#Chk_1030_1100').attr('checked','checked');
				
			if(ev.AvailableTimes.indexOf('11:00 AM - 11:30 AM') > -1)	
				$('#Chk_1100_1130').attr('checked','checked');
				
			if(ev.AvailableTimes.indexOf('11:30 AM - 12:00 PM') > -1)	
				$('#Chk_1130_1200').attr('checked','checked');
				
			if(ev.AvailableTimes.indexOf('12:00 PM - 12:30 PM') > -1)	
				$('#Chk_1200_1230').attr('checked','checked');
			
			if(ev.AvailableTimes.indexOf('12:30 PM - 01:00 PM') > -1)	
				$('#Chk_1230_0100').attr('checked','checked');
				
			if(ev.AvailableTimes.indexOf('01:00 PM - 01:30 PM') > -1)	
				$('#Chk_0100_0130').attr('checked','checked');
				
			if(ev.AvailableTimes.indexOf('01:30 PM - 02:00 PM') > -1)	
				$('#Chk_0130_0200').attr('checked','checked');
				
			if(ev.AvailableTimes.indexOf('02:00 PM - 02:30 PM') > -1)	
				$('#Chk_0200_0230').attr('checked','checked');								
				
			if(ev.AvailableTimes.indexOf('02:30 PM - 03:00 PM') > -1)	
				$('#Chk_0230_0300').attr('checked','checked');
				
			if(ev.AvailableTimes.indexOf('03:00 PM - 03:30 PM') > -1)	
				$('#Chk_0300_0330').attr('checked','checked');
				
			if(ev.AvailableTimes.indexOf('03:30 PM - 04:00 PM') > -1)	
				$('#Chk_0330_0400').attr('checked','checked');
				
			if(ev.AvailableTimes.indexOf('04:00 PM - 04:30 PM') > -1)	
				$('#Chk_0400_0430').attr('checked','checked');
				
			if(ev.AvailableTimes.indexOf('04:30 PM - 05:00 PM') > -1)	
				$('#Chk_0430_0500').attr('checked','checked');
				
			if(ev.AvailableTimes.indexOf('05:00 PM - 05:30 PM') > -1)	
				$('#Chk_0500_0530').attr('checked','checked');
				
			if(ev.AvailableTimes.indexOf('05:30 PM - 06:00 PM') > -1)	
				$('#Chk_0530_0600').attr('checked','checked');							
		} 															 						
	},
	get_value:function(node,ev){						
		
		
	},
	focus:function(node){
		var a = node.childNodes[1]; a.select(); a.focus(); 
	}


Hi,

You can catch onEventSave event, it provides such information
docs.dhtmlx.com/doku.php?id=dhtm … neventsave
Or you can check it with codeif(scheduler.getState().new_event){ //creating new event }else{ //updating existing one }

You can use onEventSave event and validate before saving.
Here is how you can get list of all events that occur at some dayvar from = scheduler.date.day_start(new Date(event.start_date)); var to = scheduler.date.add(from, 1, "day"); var evs = scheduler.getEvents(from, to);//events of that day

I as for the code, I couldn’t exactly reproduce the problem, but here is few thoughts:

  1. Initializing calendar inside of set_value method will create additional calendar each time user opens lightbox. That will lead to unreasonable memory consumption.
    Try creating calendar after ligthbox is opened, and destroy it when it’s closed:scheduler.attachEvent("onLightbox", function(){ scheduler.myCalendar = new dhtmlXCalendarObject(['StartDateCalendar1','EndDateCalendar']); scheduler.myCalendar.hideTime(); }); scheduler.attachEvent("onAfterLightbox", function(){ scheduler.myCalendar.unload(); });
  2. When i’ve tested it, calendar was not visible due to big z-index of the ligthbox, make sure you’ve set big enought z-index to calendar box <style> .dhtmlxcalendar_container{ z-index: 99999; } </style>

Thank you very much for all you help except the follwoing issue. You have been very very helpful.

I am putting the code you mentioned in the onBeforeLightbox instead of onEventSave to restrict users from creating more than 1 event per day but I am getting zero in the evs.length for a day (Jun 17t) where I already have one previous created event. Please see pic for more info.

scheduler.attachEvent("onBeforeLightbox", function(event_id) { var from = scheduler.getEvent(event_id).start_date; var to = scheduler.date.add(from, 0, "day"); var evs = scheduler.getEvents(from, to);//events of that day alert('From Date : ' + from + " To Date :" + to + " # of Events :" + evs.length); return true; });


You need to have at least some interval bettween from and to
Change
var to = scheduler.date.add(from, 0, “day”);
as
var to = scheduler.date.add(from, 1, “minute”);

Hi Stanislav ,
I am still having issue restricting users from creating more than 1 event per day.

I can get the right number of total events for a day with your logic but it still creates the event with my following logic if there is already an event on that date and then if I click on the previously created event for the same date, it considers it a new event.

scheduler.attachEvent("onBeforeLightbox", function(event_id) { 				
					if(scheduler.getState().new_event)
					{ alert('New');
						var GetCurrentFromDate = scheduler.getEvent(event_id).start_date; 
														
						var GetCurrentToDate = scheduler.date.add(GetCurrentFromDate, 23, "hour");	
						GetCurrentToDate = scheduler.date.add(GetCurrentToDate, 59, "minute");	 
						
						GetCurrentToDate.setSeconds(GetCurrentToDate.getSeconds() + 59);
						
						var GetEvents = scheduler.getEvents(GetCurrentFromDate, GetCurrentToDate);			
						alert('From Date :  ' + GetCurrentFromDate  + "    To Date :" + GetCurrentToDate +  "    # of Events :" + GetEvents.length );	
						 
						if(GetEvents.length == 1)					
						{			
							scheduler.config.buttons_right = (scheduler.getState().new_event) ? [] : ["dhx_delete_btn"];				
							scheduler.resetLightbox();		
							return true;
						}
						else
						{
							alert('There is Alreay An Event For ' + GetCurrentFromDate);						
							return false;	
						}				
					}
					else
					{	alert('Old');
						scheduler.config.buttons_right = (scheduler.getState().new_event) ? [] : ["dhx_delete_btn"];				
						scheduler.resetLightbox();		
						return true;	
					}							
				});

Regards.


In addition to return false from onBeforeLightbox , when event was blocked, you need to call

scheduler.deleteEvent(event_id);

which will remove newly created and blocked event.

Or you can use the existing logic, but instead of onBeforeLightbox use onBeforeEventChanged event.

Hi Stanislav,
I added a line you mentioned to my code(scheduler.deleteEvent(event_id);). It cancels a new event if there is already an event on the same day but if I open previously created event(My previously created event text (1- 2013-06-17)) on the same day it even considers it a new event and if I click cancel button on the lightbox for that event then it removes that event form scheduler.

	scheduler.locale.labels.section_Assessor = "Scheduler"; // This is a section  in a lightbox
								
				scheduler.config.details_on_create = true;
				scheduler.config.details_on_dblclick = true;
				scheduler.config.drag_move = false;
				scheduler.config.show_loading = true;
				scheduler.config.xml_date = "%Y-%m-%d %H:%i";  
				scheduler.config.start_on_monday = true;
				scheduler.config.full_day = true;
															
				scheduler.createTimelineView({
					name: "TopTimeline",
					x_unit:	"day",
					x_date:	"%D, %d %M %y ",
					x_step:	1,
					x_size: 7,		
					y_unit:	AssessorsArray,
					y_property:"UserID",
					render:"bar"
				});	
				
scheduler.form_blocks["my_editor"]={
					render:function(sns){
						return "<div class='dhx_cal_ltext' style='height:650px;'> <table width='550px' cellspacing='3'> <tbody> <tr> <td class='LightBoxHeadingCell'> Location : </td> <td class='LightBoxNormalCell'> <select name='LocationDropDown' id='LocationDropDown' onchange='LocationDropDownOnChange();' style='width:150px;'> <option selected = '' value='Evaluators Office'>Evaluators Office</option> <option value='Clinic'>Clinic</option> </select> </td> <td class='LightBoxHeadingCell'> Status : </td> <td class='LightBoxNormalCell'> <select style='width:150px' name='StatusDropDown' id='StatusDropDown' disabled=disabled> <option value='Available'>Available</option> <option selected = '' value='UnAvailable'>UnAvailable</option> </select> </td> </tr> <tr id='ReasonRow' style='display:none;'> <td class='LightBoxHeadingCell'> Reason : </td> <td> <select style='width:150px' name='ReasonDropDown' id='ReasonDropDown'> <option selected = '' value=''></option> <option value='Personal Leave'>Personal Leave</option> <option value='Sick'>Sick</option> <option value='Stat Holiday'>Stat Holiday</option> <option value='Sick'>Sick</option> <option value='Training'>Training</option> <option value='Vacation'>Vacation</option> </select> </td> <td class='LightBoxHeadingCell'> &nbsp; </td> <td class='LightBoxHeadingCell'> &nbsp; </td> </tr> <tr id='ReserveRow'> <td class='LightBoxHeadingCell'> Reserve Type : </td> <td> <select style='width:150px' id='ReserveTypeDropDown' name='ReserveTypeDropDown'> <option selected = '' value=''></option> <option value='Regular'>Regular</option> <option value='All Call'>All Call</option> </select> </td> <td class='LightBoxHeadingCell'> Reserved For : </td> <td> <select style='width:150px' id='ReservedForDropDown' name='ReservedForDropDown'> <option selected = '' value=''></option> <option value='Any'>Any</option> <option value='CAT Only'>CAT Only</option> <option value='In-Person Only'>In-Person Only</option> </select> </td> </tr> <tr id='DatesRow'> <td class='LightBoxHeadingCell' id='StartDateHeadingTD'> Start Date : </td> <td id='StartDateCalendarTD'> <input type='text' id='StartDateCalendar'> </td> <td class='LightBoxHeadingCell' id='EndDateHeadingTD' style='display:none;'> End Date : </td> <td id='EndDateCalendarTD' style='display:none;'> <input type='text' id='EndDateCalendar'> </td> </tr> <tr id='AvailableTimesRow'> <td colspan='4'> <table width='500px' cellspacing='1' style='margin-top: 5px;border: 1px solid black;' id='AvailableTimesTable'> <tbody> <tr> <td colspan='2' class='LightBoxHeadingCell'> Available Times : </td> </tr> <tr> <td class='AvailableTimes'> <input type='checkbox' name='AvailableTimesCheckboxes' value='08:00 AM - 09:00 AM;'>08:00 AM - 09:00 AM </td> <td class='AvailableTimes'> <input type='checkbox' name='AvailableTimesCheckboxes' value='08:30 AM - 09:30 AM;'>08:30 AM - 09:30 AM </td> <td class='AvailableTimes'> <input type='checkbox' name='AvailableTimesCheckboxes' value='09:00 AM - 10:00 AM;'>09:00 AM - 10:00 AM </td> <td class='AvailableTimes'> <input type='checkbox' name='AvailableTimesCheckboxes' value='09:30 AM - 10:30 AM;'>09:30 AM - 10:30 AM </td> </tr> <tr> <td class='AvailableTimes'> <input type='checkbox' name='AvailableTimesCheckboxes' value='10:00 AM - 11:00 AM;'>10:00 AM - 11:00 AM </td> <td class='AvailableTimes'> <input type='checkbox' name='AvailableTimesCheckboxes' value='10:30 AM - 11:30 AM;'>10:30 AM - 11:30 AM </td> <td class='AvailableTimes'> <input type='checkbox' name='AvailableTimesCheckboxes' value='11:00 AM - 12:00 PM;'>11:00 AM - 12:00 PM </td> <td class='AvailableTimes'> <input type='checkbox' name='AvailableTimesCheckboxes' value='11:30 AM - 12:30 PM;'>11:30 AM - 12:30 PM </td> </tr> <tr> <td class='AvailableTimes'> <input type='checkbox' name='AvailableTimesCheckboxes' value='12:00 PM - 01:00 PM;'>12:00 PM - 01:00 PM </td> <td class='AvailableTimes'> <input type='checkbox' name='AvailableTimesCheckboxes' value='12:30 PM - 01:30 PM;'>12:30 PM - 01:30 PM </td> <td class='AvailableTimes'> <input type='checkbox' name='AvailableTimesCheckboxes' value='01:00 PM - 02:00 PM;'>01:00 PM - 02:00 PM </td> <td class='AvailableTimes'> <input type='checkbox' name='AvailableTimesCheckboxes' value='01:30 PM - 02:30 PM;'>01:30 PM - 02:30 PM </td> </tr> <tr> <td class='AvailableTimes'> <input type='checkbox' name='AvailableTimesCheckboxes' value='02:00 PM - 03:00 PM;'>02:00 PM - 03:00 PM </td> <td class='AvailableTimes'> <input type='checkbox' name='AvailableTimesCheckboxes' value='02:30 PM - 03:30 PM;'>02:30 PM - 03:30 PM </td> <td class='AvailableTimes'> <input type='checkbox' name='AvailableTimesCheckboxes' value='03:00 PM - 04:00 PM;'>03:00 PM - 04:00 PM </td> <td class='AvailableTimes'> <input type='checkbox' name='AvailableTimesCheckboxes' value='03:30 PM - 04:30 PM;'>03:30 PM - 04:30 PM </td> </tr> <tr> <td class='AvailableTimes'> <input type='checkbox' name='AvailableTimesCheckboxes' value='04:00 PM - 05:00 PM;'>04:00 PM - 05:00 PM </td> <td class='AvailableTimes'> <input type='checkbox' name='AvailableTimesCheckboxes' value='04:30 PM - 05:30 PM;'>04:30 PM - 05:30 PM </td> <td class='AvailableTimes'> <input type='checkbox' name='AvailableTimesCheckboxes' value='05:00 PM - 06:00 PM;'>05:00 PM - 06:00 PM </td> <td class='AvailableTimes'> &nbsp; </td> <td class='AvailableTimes'> &nbsp; </td> <td class='AvailableTimes'> &nbsp; </td> </tr> </tbody> </table> </td> </tr> <tr id='AssessorNotesRow'> <td valign='top' class='LightBoxHeadingCell'> Assessor Notes : </td> <td colspan='3'> <textarea name='AssessorNotes' style='border: solid 1px #CCC;width:390px;height:50px;' id='AssessorNotes'> </textarea> </td> </tr> <tr id='AssessmentsDivRow' style='display:none;'> <td colspan='4' class='LightBoxHeadingCell'> <span style='font-size:10px;'>Assessments :</span> <div id='AssessmentsGrid' style='margin-top:5px;width:500px;'> </div> </td> </tr> <tr id='BookingNotesRow'> <td valign='top' class='LightBoxHeadingCell'> Booking Notes : </td> <td td colspan='3'> <textarea name='BookingNotes' style='border: solid 1px #CCC;width:390px;height:50px;' id='BookingNotes'> </textarea> </td> </tr> </tbody> </table> </div>";
					},
					set_value:function(node,value,ev){ 						 
						 $('#StartDateCalendar').val(ev.StartDate || ""); 
						 $('#EndDateCalendar').val(ev.EndDate || "");							 
						 $("#ReasonDropDown").val(ev.Reason || ""); 
						 $("#ReserveTypeDropDown").val(ev.ReserveType || ""); 					
						 $("#ReservedForDropDown").val(ev.ReservedFor || ""); 					 		
						 $('#AssessorNotes').val(ev.AssessorNotes || "");	
						 $('#BookingNotes').val(ev.BookingNotes || "");								
						 $('#AvailableTimesTable input:checkbox').attr('checked','');
						 
						if(ev.AvailableTimes)
						{						
							var CurrentArray = ev.AvailableTimes.split(";");							
							for(var qqq = 0; qqq < CurrentArray.length; qqq++)
							{
								$('#AvailableTimesTable input[type=checkbox]').each(function () {																		
									if ($(this).val() == (CurrentArray[qqq] + ";")) 
										this.checked = "true";		
								});		
							}										
						} 																	 						
					},
					get_value:function(node,ev){		//alert('get_value:function(node,ev)' + ev.StartDate);			
										
						ev.LocationType = $("#LocationDropDown").val(); 
						ev.Reason = $("#ReasonDropDown").val(); 
						ev.ReserveType =  $("#ReserveTypeDropDown").val(); 		
						ev.ReservedFor = $("#ReservedForDropDown").val(); 						
						ev.StartDate = $('#StartDateCalendar').val();	
						ev.EndDate = $('#EndDateCalendar').val();	
						ev.AssessorNotes = $('#AssessorNotes').val();	
						ev.BookingNotes = $('#BookingNotes').val();														
					},
					focus:function(node){					
						node.getElementsByTagName("select")[0].focus(); 						
					}
				}
				
//===============
				//Data loading
				//===============
				scheduler.config.lightbox.sections  = [{name:"Assessor", height:130, map_to:"text", type:"my_editor"}]		
								
				scheduler.attachEvent("onBeforeLightbox", function(event_id) { 						
					if(scheduler.getState().new_event)
					{ alert('New');
						var GetCurrentFromDate = scheduler.getEvent(event_id).start_date; 														
						var GetCurrentToDate = scheduler.date.add(GetCurrentFromDate, 23, "hour");	
						GetCurrentToDate = scheduler.date.add(GetCurrentToDate, 59, "minute");	 						
						GetCurrentToDate.setSeconds(GetCurrentToDate.getSeconds() + 59);
						
						var GetEvents = scheduler.getEvents(GetCurrentFromDate, GetCurrentToDate);			
						alert('From Date :  ' + GetCurrentFromDate  + "    To Date :" + GetCurrentToDate +  "    # of Events :" + GetEvents.length );	
						 
						if(GetEvents.length == 1)					
						{			
							scheduler.config.buttons_right = (scheduler.getState().new_event) ? [] : ["dhx_delete_btn"];				
							scheduler.resetLightbox();		
							return true;
						}
						else
						{
							alert('There is Alreay An Event For ' + GetCurrentFromDate);		
							scheduler.deleteEvent(event_id);				
							return false;	
						}				
					}
					else
					{	alert('Old');
						scheduler.config.buttons_right = (scheduler.getState().new_event) ? [] : ["dhx_delete_btn"];				
						scheduler.resetLightbox();		
						return true;	
					}
												
				});
				
scheduler.attachEvent("onLightbox", function (event_id){	alert("onLightbox");										
					scheduler.myCalendar = new dhtmlXCalendarObject(['StartDateCalendar','EndDateCalendar']);
  				 	scheduler.myCalendar.hideTime();	
								
					var GetLightBoxAssessorID = scheduler.getEvent(event_id).UserID;  
				        				        
				        $("select[event_id='LocationDropDown'] > option:gt(1)").remove();
				        
					for(var aaa = 0; aaa < gAssessorCompanyAssociationssArray.length; aaa++) 
					{ 
						if(scheduler.getEvent(event_id).UserID == gAssessorCompanyAssociationssArray[aaa].AssessorUserID && gAssessorCompanyAssociationssArray[aaa].Company != '')												 
							 $('#LocationDropDown').append(new Option(gAssessorCompanyAssociationssArray[aaa].Company, gAssessorCompanyAssociationssArray[aaa].CompanyID));											
					}  				
					
					if(scheduler.getEvent(event_id).LocationType == 'Evaluators Office' || scheduler.getEvent(event_id).LocationType == 'Clinic')	
					{ 					 	
						$('#LocationDropDown option').each(function() {
						if(scheduler.getEvent(event_id).LocationType == this.text){
							$(this).attr("selected", "selected");	
							return true;									
						}});				 
					}
					else
					{	
						for (var k = 0; k < gAssessorCompanyAssociationssArray.length; k++) 
						{
							if(gAssessorCompanyAssociationssArray[k].CompanyID == scheduler.getEvent(event_id).LocationType)
							{								
								$('#LocationDropDown option').each(function() { 
								if(gAssessorCompanyAssociationssArray[k].Company == this.text){
									$(this).attr("selected", "selected");	
									return true;									
								}});
							}
						}				 
					}						        															 
				  }); 
				  
				scheduler.attachEvent("onAfterLightbox", function(){ //alert("onAfterLightbox");	
					scheduler.myCalendar.unload();
				});		
				
				
				scheduler.attachEvent("onEventSave",function(id,data,is_new_event){   alert("onEventSave");									
					if($('#LocationDropDown option:selected').text() != 'Clinic')	
				  	{
				  		if (($('#ReserveTypeDropDown option:selected').text() != ""))
						{
							if (($('#ReservedForDropDown option:selected').text() != ""))
							{
								if($('#StartDateCalendar').val() !='' )
								{
									if($('input:checkbox:checked').length > 0)
									{										
											return true;																	
									}
									else
										alert('Please Check Available Times.');
								}
								else
									alert('Please Enter Date.');
							}							
							else
								alert('Please Select Reserved For.');
						
						}
						else
							alert('Please Select Reserve Type.');									  			
				  	}
				  	else
				  	{
				  		if (($('#ReasonDropDown option:selected').text() != ""))
						{		
							if($('#StartDateCalendar').val() !='' )
							{
								if($('#EndDateCalendar').val() !='' )
								{
									var CurrentStartDateCalendar = $('#StartDateCalendar').val();
									var CurrentEndDateCalendar = $('#EndDateCalendar').val();
									
									if(Date.parse(CurrentEndDateCalendar).compareTo(Date.parse(CurrentStartDateCalendar)) > -1)									
										return true;	
									else
										alert('End Date Should Be Equal To Or Greater Than Start Date.');								
								}
								else
									alert('Please Enter End Date.');
							}
							else
								alert('Please Enter Start Date.');
						}
						else
							alert('Please Select Reason.');			  				
				  	} 
					
					return false;					
				}) 






Which version of scheduler you are using ?

deleting event after scheduler.getState().new_event check must not affect old events
and returning false from onbeforeLightbox must correctly finish new_event state for latest scheduler

I am using dhtmlxScheduler v.3.0 build 110727

Its quite old version, as API is backward compatible you can update to latest one ( you can check with gpl version from the site )