I want to display a message when we navigate through calendar control in Kendo. But my condition is whenever we enter into new year I should display a message.
Ex: current month is July - 2013. when I navigate to next month Aug - 2013 --> In this case I don't want to display a message.
If we are in Dec - 2013, when I click next navigation button --> In this case I wanted to display a message like entered new year.
Same case for previous navigation also. When we are in Jan - 2013, if I press previous button it will enter into Dec - 2012 --> In this case also I wanted to display a message.
Is there any way to get it done?
Try defining the navigate
handler as:
navigate: function () {
var cur = this._current;
var prev = this._previous;
if (prev && cur && prev.getFullYear() !== cur.getFullYear()) {
alert("year change");
}
this._previous = this._current;
}
What I do is get current date (_current
) that is a reference date in current calendar view, then get its year and compare this with the previous date.
In addition, and since there is no previous
date in a Calendar, I save it for using in the next navigation event.
Example here: http://jsfiddle.net/OnaBai/jf2XK/