Issue 194: problem with date objects in cells
Status:  Done
Owner: ----
Closed:  Nov 2009
Reported by bwscrapb...@gmail.com, Nov 17, 2009
we are trying to make the day cells in the month view clickable so when
clicked they bring the person to the agendaDay for the day clicked.

The problem I am having is the dat object is not lining up correctly on
previous or next months. each month  says the date objects is for the
current month

I added an a tag in the cell and added an onclick call to alert to show the
date object I am accessing

here is the code I am using in fullcalendar.js

				for (j=0; j<colCnt; j++) {
					
					s += "<td class='fc-" +
						dayIDs[d.getDay()] + ' ' + // needs to be first
						tm + '-state-default fc-day' + (i*colCnt+j) +
						(j==dit ? ' fc-leftmost' : '') +
						(rowCnt>1 && d.getMonth() != month ? ' fc-other-month' : '') +
						(+d == +today ?
						' fc-today '+tm+'-state-highlight' :
						' fc-not-today') + "'>" +
// here is my change
(showNumbers ? "<a href='#' onClick='alert(\" " + d + "\")'><div
class='fc-day-number'>" + d.getDate() + "</div>" : '') +
						"<div class='fc-day-content'><div>&nbsp;</div></div></a></td>";
					addDays(d, 1);
					if (nwe) {
						skipWeekend(d);
					}
				}

What steps will reproduce the problem?
1. bring up the calendar and click on a day in the current month the alert
will show the correct date object for the day clicked
2. now click the next button to move to december and repeat step 1 the date
objects reflect the date placement in november  and show november dates
(i.e. the Sunday in row one reads Nov 1 2009


What is the expected output? What do you see instead?

clicking on the date should spawn an alert that contains the same date
object as the date being rendered in the day cell.


What version of the product are you using? On what operating system?
1.4.1
windows xp 
firefox 3.5 , chrome, ie6

Please provide any additional information below.

Nov 17, 2009
#1 gle...@gmail.com
I don't understand why you add a <a> tag , there's already a dayClick event.
Just validate that the current view is month and switch it to agenda.

dayClick: function(dayDate, allDay, jsEvent, view) {
	if (view.name.toString() == 'month') {
		// dayDate is a Date object holding the current date and time
	}
}
Nov 27, 2009
Project Member #2 adamrs...@gmail.com
glenza is right about using dayClick, it is the easiest way.

but back to the bug you originally filed... this is related to what fullcalendar does
internally to render the calendar. that code you supplied is executed only the FIRST
time the month is rendered, and subsequent months just tweak that dom structure (see
the `else` statement with the comment //NOT first time, reuse as many cells as
possible). you'd have to also do your stuff in the else.

but its best to use event hooks (like dayClick). if you need more control,
`dayRender` is in the pipeline
(https://code.google.com/p/fullcalendar/issues/detail?id=191)

respond if any more questions. hope this helps,
adam
Status: Done