dhtmlxscheduler - using onBeforeEventChange with unit view

Hi,



I’m trying to use onBeforeViewChange when switching to a unit view, in order to load new data into the calendar.



The problem I have is that the code I use in the attached event is executed but the view goes back to the previous view (so if I am in week view, I click the unit tab, the logic is performed but the view stays as week view). I am using onBeforeViewChange instead of onViewChange (which does switch view correctly) so that I can examine the old view and stop the event being called when Next and Previous are pressed.



Here is my code:



scheduler.createUnitsView(‘unit’,‘user’,keyLabelPairs);



scheduler.attachEvent(“onBeforeViewChange”, function (old_mode, old_date, mode, date){

     //this condition stops this being called when using next/previous arrows in unit view

     if (mode == ‘unit’ && old_mode !=‘unit’) {

         //clear the scheduler

         scheduler.clearAll();

//fetch events for users of that department from the Compare view

     document.getElementById(‘scheduler_progress’).style.visibility = ‘visible’;

            //loop through key label pairs

            for (var i=0; i<keyLabelPairs.length; i++) {

                var pair = keyLabelPairs[i];

                //method for DWR retrieval of more appointments

                displayAppointmentsForNewUser(pair.key);

            }

     document.getElementById(‘scheduler_progress’).style.visibility = ‘hidden’;

}



});



Any feedback you can give me about this would be appreciated.



Cheers

Paul


Hello,


onBeforeViewChange event should return true to allow view change:


scheduler.attachEvent(“onBeforeViewChange”, function (old_mode, old_date, mode, date){





return true;


}

Ah right! I’ll give that a try.
Thanks for the quick response!

Paul