Hi to all,
I am trying to extend the WebCalendar with client side events like onmouseout but I am unable to get it to work.
A code snippet you can find here below. I am enumerating through the days, when a condition is true I am trying to add the onmouseover event to it like this.
document.getElementById(oCalendar.Days[i].element.id).onmouseover = 'BLOCKED SCRIPTalert("hi!");';
The oCalendar.Days[i].element.id gives the id of the table cell of that particular day.
Can someone tell me how it can work?
Thanks.
Hi,
To process events you may use WebCalendar shortcuts, though your approach also might work. The Days[index].element is already reference to element, so there is no need to use getElementById. Below is example:
<script type="text/javascript">function myOverFunct(evt){ var elem = evt.srcElement; if(!elem) elem = evt.target; var id = elem ? elem.id : null; if(!id) return; var cal = igcal_getCalendarById(null, elem); id = id.substring(id.length - 2); if(id.charAt(0) == 'd') id = id.substring(1); id = parseInt(id); var day = cal.Days[id]; alert('id=' + id);}function WebCalendar1_InitializeCalendar(oCalendar){ var days = oCalendar.Days; var i = days.length; while(i-- > 0) ig_shared.addEventListener(days[i].element, "mouseover", myOverFunct);}</script>
<igsch:WebCalendar ID="WebCalendar1" runat="server"> <ClientSideEvents InitializeCalendar="WebCalendar1_InitializeCalendar"></ClientSideEvents></igsch:WebCalendar>
This works great, thanks a lot.