Reputation: 115
basically any hard coded values will work. However, when I build an array of even object and then set it, no events are added to the calendar.
function getCalendarEvents() {
var events = new Array();
$(".ms-srch-item:visible").each(function () {
events.push(
{
title: $(this).find(".assigned_resource").html(),
start: new Date($(this).find(".start_date").attr("date")),
end: new Date($(this).find(".end_date").attr("date"))
});
});
return events;
}
$(document).ready(function () {
$("#testme").click(function () {
var array = [{ title: 'All Day Event', start: new Date(2013, 8, 5) }];
array = getCalendarEvents();
var calendar = $('#calendar').fullCalendar({
header: {
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek'
},
events:array
});
$(".fc-button-agendaWeek").click(function () {
$(".fc-agenda-allday").next().next().hide();
});
});
});
I have checked the array object and it is in the correct form with proper values. But for some reason I get no events. If I dont use the function and use the hard coding it works for that one event. See any problems with my code?
EDIT:
here is working code (ignore color stuff that I added):
function getCalendarEvents() {
if(calendarColors.length < 1)
{
//build colors first time ...do it here because we want to wait for async clients call to finish
BuildCalendarColorsMap();
}
var events = new Array();
$(".ms-srch-item:visible").each(function () {
var client = $(this).find(".client").html();
//junk check testing
if (client && client.indexOf('<strong>Client:</strong>') != -1) {
client = client.replace('<strong>Client:</strong>', '');
var start = new Date($(this).find(".start_date").attr("date"));
var end = new Date($(this).find(".end_date").attr("date"));
var title = client + ": " + $(this).find(".assigned_resource").html().replace('<strong>Assigned Resource:</strong>', "");
var color = getCalendarColor(client);
events.push(
{
title: title,
start: new Date(start.getFullYear(), start.getMonth(), start.getDate()),
end: new Date(end.getFullYear(), end.getMonth(), end.getDate()),
color: color
});
}
});
return events;
}
Upvotes: 1
Views: 1900
Reputation: 741
Check the string for the start
and end
attributes.
The string may be in ISO8601 format, IETF format, or a UNIX timestamp (in either integer or string form).
Upvotes: 1