javascript - fullcalendar plugin does not add events from array object -
basically hard coded values work. however, when build array of object , set it, no events added 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 array object , in correct form proper values. reason no events. if dont use function , use hard coding works 1 event. see problems code?
edit:
here working code (ignore color stuff added):
function getcalendarevents() { if(calendarcolors.length < 1) { //build colors first time ...do here because want wait async clients call 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; }
check string start
, end
attributes.
the string may in iso8601 format, ietf format, or unix timestamp (in either integer or string form).
Comments
Post a Comment