Hi there, I’m using calendar 3.0 and I found something weird with the onChange event. It seems to be fired on the click of the selector. Here’s the example code I use:
<input type="text" id="txtCalendrier" />
<script type="text/javascript">
//var dateCourante = new Date();
if (typeof(dhtmlXCalendarObject) !== 'undefined')
{
dhtmlXCalendarObject.prototype.langData["fr"] = {
dateformat: '%Y.%m.%d',
monthesFNames: ["Janvier","Février","Mars","Avril","Mai","Juin","Juillet","Août","Septembre","Octobre","Novembre","Décembre"],
monthesSNames: ["Jan","Fév","Mars","Avr","Mai","Juin","Juil","Août","Sept","Oct","Nov","Déc"],
daysFNames: ["Dimanche","Lundi","Mardi","Mercredi","Jeudi","Vendredi","Samedi"],
daysSNames: ["Di","Lu","Ma","Me","Je","Ve","Sa"],
weekstart: 7 // Chiffre de 1(Lundi) à 7(Dimanche)
}
}
calendrier = new dhtmlXCalendarObject('txtCalendrier');
calendrier.loadUserLanguage("fr");
calendrier.setSkin('dhx_skyblue');
calendrier.hideTime();
calendrier.attachEvent("onChange", function(date, state)
{
alert("A change was made");
});
</script>
As the documentation explains, the “onChange” event should be fired when the year, month or day in the selector changes, which is indeed the case, as should be expected. What isn’t however is that the “onChange” is also fired when I click on the selector to make the calendar appear. I mean, I haven’t even changed anything, I just clicked and the event triggered. Is this behavior intentional?
If you could help me with this, I’d be grateful.
Thanks in advance,
Osu