| Issue 607: | Error when trying to display weekly or daily view | |
| 1 person starred this issue and may be notified of changes. | Back to list |
I am using fullCalendar in a portlet. The monthly view shows just fine. However, when a user clicks the button for the agendaDay or agendaWeek views, the following error shows in the Firebug console.
G.find("tr:eq(" + i + ") td div")[0] is undefined
It looks like the fullCalendar script is looking a DOM element and not finding it for some reason.
Here is the initialization code for the fullCalendar instance:
jQuery(ecSel).fullCalendar({
//theme: true,
defaultView: dv, //monthly, agendaWeek or agendaDay
weekends: dw, //true or false
slotMinutes: mb, //15 or 30
firstHour: fh, //0-23
header: {
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,agendaDay'
},
buttonText: {
agendaWeek: "Weekly",
agendaDay: "Daily",
basicWeek: "Basic Week",
basicDay: "Basic Day",
month: "Monthly",
today: "Today"
},
loading: function(isLoading, view) {
jQuery.getScript(cvp.getContextPath()+"/js/jquery.blockUI.js", function() {
if(isLoading){
jQuery(cpSelector).block({
message: "<img src='"+cvp.getContextPath()+"/images/icon_loading.gif' align='absmiddle' alt='Loading...' /> Fetching events..."
});
}else{
jQuery(cpSelector).unblock();
}
});
},
// TODO: finish json to array conversion and posting of all data
events: function(start, end, callback) {
var formData = jQuery(formSel).serialize();
var gtDate = cvp.ut.formatIsoDate(start);
var ltDate = cvp.ut.formatIsoDate(end);
formData += ">Date="+gtDate+"<Date="+ltDate;
jQuery.ajax({
url: jQuery(formSel).attr("action"),
type: "POST",
dataType: 'text',
data: formData,
success: function(jsonStr) {
console.log(jsonStr);
var events = [];
try{
jsonObj = jQuery.parseJSON(jsonStr);
jQuery.each(jsonObj.events.event, function() {
//need dates in iso format 1994-11-05T13:15:30Z
var stDate = this.dateStart__.replace(" ","T")+"Z";
var endDate = this.dateEnd__.replace(" ","T")+"Z";
events.push({
id: this.eventId__,
title: this.title__,
allDay: this.allDay__,
start: stDate,
end: endDate,
recurring: this.recurring__,
tbd: this.timeTBD__,
hasAttachments: this.hasAttachments__
});
});
}catch(err){
jQuery(msgSel).html("There was an error parsing the events");
jQuery(msgSel).show();
cvp.ut.log("There was an error parsing the events.");
}
cvp.ut.log(events);
callback(events);
}
});
},
eventRender: function(event, element) {
if(event.recurring){
jQuery(element).find("a:first").prepend('<img src="'+cvp.getIcons()["recurring"]+'" alt="recurring" border="0" />');
}
if(event.allDay){
jQuery(element).find("a:first").prepend('<img src="'+cvp.getIcons()["allDay"]+'" alt="all day" border="0" />');
}
if(event.tbd){
jQuery(element).find("a:first").prepend('<img src="'+cvp.getIcons()["tbd"]+'" alt="tbd" border="0" />');
}
/*
if(event.hasAttachments){
jQuery(element).find("a:first").prepend('<img src="'+cvp.getIcons()["attachment"]+'" alt="recurring" border="0" />');
}
*/
// TODO: get category colors into a JS object for use here.
/*set background color based on category
jQuery(element).find("a:first").css("background-color", catColors[event.primaryCategory__]);
jQuery(element).find("span").css("background-color", catColors[event.primaryCategory__]);
*/
},
dayClick: function( date, allDay, jsEvent, view ) {
jQuery(ecSel).fullCalendar('gotoDate',date);
jQuery(ecSel).fullCalendar('changeView','agendaDay');
},
// TODO: re-factor this to use existing methods
eventClick: function(event, jsEvent, view) {
jQuery(edSel).dialog({
minWidth: 500,
minHeight: 300,
autoOpen: false
});
jQuery(edSel).dialog("open");
jQuery(edSel +" .eventDetailLoading").show();
//populate the event details container
jQuery.ajax({
url: '/nasa/esmd/viewer/eventDetails.json',
dataType: 'json',
type: 'GET',
data: {
id: event._id
},
success: function(jsonObj) {
try{
//var jsonObj = jQuery.parseJSON(jsonStr);
jQuery(edSel).attr("title",jsonObj.events.event.title__);
jQuery(edSel +" .eventId_data").html(jsonObj.events.event.eventId__);
jQuery(edSel +" .eventId").show();
jQuery(edSel +" .title_data").html(jsonObj.events.event.title__);
jQuery(edSel +" .title").show();
jQuery(edSel +" .eventData").show();
}catch(err){
jQuery(edSel +" .eventDetailMsg").html("An error occurred parsing the event details.");
jQuery(edSel +" .eventDetailMsg").show();
//console.log(err);
}
},
complete: function() {
jQuery(edSel +" .eventDetailLoading").hide();
}
});
}
});
Aug 19, 2010
I figured out that this was being caused by the code sending in the values for firstHour and blockSize as Strings and not as Integers. I changed them to Integers and now everything works beautifully. Sorry to take up bandwidth. Hopefully this will help someone else in the future if they run into the same problem.
Aug 25, 2010
no prob. glad you got it to work
Status:
Done
|
|
| ► Sign in to add a comment |
FYI, the basicWeek and basicDay views work fine. It is just the agendaWeek and agendaDay views that are creating the error: G.find("tr:eq(" + i + ") td div")[0] is undefined