I am writing a custom calendar, that consists of two parts, one div showing the month grid, and a second div showing the events for the selected date. The current month's calendar grid loads automatically, and the display of daily events works correctly. However, when the user clicks the button to view the next or previous month, clicking on the dates no longer works. Also, changing the month no longer works on the dynamically-loaded calendar.
This is the jQuery code I am using:
<script type="text/javascript">
$(document).ready(
function() {
$('div.calendar_events').text('To view the events on any of the highlighted dates, simply click the date.');
$('div.number').click(
function(e) {
e.preventDefault();
var theDate = $(this).attr('id').split('-');
$('div.calendar_events').load('ajax/calendar_events.php?month=' + theDate[1] + '&day=' + theDate[2] + '&year=' + theDate[3]);
});
$('a.changemonth').click(
function(e) {
e.preventDefault();
var theDate = $(this).attr('id').split('-');
$('div.calendar').load('ajax/calendar_view.php?month=' + theDate[1] + '&year=' + theDate[2]);
});
});
</script>