reload on second save

Hi,

I’ve used some code to reload the scheduler after a change has been made:

var _ifreload = 1;
			 scheduler.attachEvent("onEventSave",function(id,data,is_new_event){
				if (!data.Type) {
					dhtmlx.alert("You must select at least 1 activity");
					return false;
				}
		        _ifreload = 1;
				return true;
			})

            scheduler.attachEvent("onEventCancel", function(event_id, is_new_event) {
                _ifreload = 0;
            });
            scheduler.attachEvent("onAfterLightbox", function() {
                if (_ifreload) {
                    scheduler.clearAll();
					scheduler.load("XML/Calendar/DataSave.php?uid="+scheduler.uid());
					dhxTasksGrid.clearAll();
					dhxTasksGrid.load("XML/Startpage/JobsToday.php"); 
					dhxJobGrid.clearAll(); 
					dhxJobGrid.load("XML/Job/JobsListData.php"); 
                }
            });



			scheduler.createUnitsView("unit","EngineerID",sections,5,1);
			scheduler = dhxLayout.cells("a").view("Scheduler").attachScheduler(new Date(), "unit", '<div class="dhx_cal_tab" name="day_tab" style="right:204px;"></div><div class="dhx_cal_tab" name="week_tab" style="right:140px;"></div><div class="dhx_cal_tab" name="month_tab" style="right:280px;"></div><div class="dhx_cal_tab" name="year_tab" style="right:280px;"></div><div class="dhx_cal_tab" name="unit_tab" style="right:280px;"></div>');
			
   
			scheduler.load("XML/Calendar/DataSave.php?uid="+scheduler.uid());
			
			scheduler.updateView(); 

			var dp = new dataProcessor("XML/Calendar/DataSave.php");
			dp.attachEvent("onAfterUpdate", function(sid, action, tid, tag){
			   scheduler.ClearAll();
			   scheduler.load("XML/Calendar/DataSave.php?uid="+scheduler.uid());
			})
			dp.init(scheduler);

This works when i change an appointment the first time, but when i try to change the appointment again, it won’t save. I will have to refresh the page in order to change the appointment.

Anyone any idea what might cause this?

Never mind, found the solution.

dp.attachEvent("onAfterUpdate", function(sid, action, tid, details){
			     if (action == "updated")
			     {
			         scheduler.load("XML/Calendar/DataSave.php");
			     }
			     if (action == "inserted")
			     {
			         scheduler.load("XML/Calendar/DataSave.php");
			     }
			     dhxTasksGrid.clearAll();
				 dhxTasksGrid.load("XML/Startpage/JobsToday.php"); 
				 dhxJobGrid.clearAll(); 
				 dhxJobGrid.load("XML/Job/JobsListData.php"); 
			});