Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Brian H. on Dec 17, 2009 17:11
open dhtmlx forum
dhtmlxCalendar Events for changing month and year

With the isYearEditable and isMonthEditable set to true, the user is allowed to change the month and year. However, the onChangeMonth event is not fired when changing the month or year in this way. Is there an event for changing these drop-downs that can be attached to a function?

Thanks!
Answer posted by Alex (support) on Dec 18, 2009 01:52

Hello,

onMonthChange event is firedonly when a month is changed by click on left or right arrow in the calendar header.

The solution can be the following:

var calendar = new dhtmlxCalendarObject('dhtmlxCalendarObj', false, {isYearEditable: true,isMonthEditable: true});

....

var onYS = calendar.onYearSelect;
var onMS = calendar.onMonthSelect;
  
calendar.onYearSelect = function(value) {
    doOnYearSelect(value);
    return onYS.apply(this,[value])
}
calendar.onMonthSelect = function(value) {
    doOnMonthSelect(value);
    return onMS.apply(this,[value])
}
/*a custom function that will be called when month changed*/
function doOnMonthSelect(value){
   /*your code here*/
}

/*a custom function that will be called when year changed*/
function doOnYearSelect(value){
   /*your code here*/
}