Note that there are some explanatory texts on larger screens.

plurals
  1. POfullCalendar - addEventSource with the color option
    primarykey
    data
    text
    <p>I have a function that dynamically adds events to the calendar. </p> <pre><code>function AddEventSourceDetailed(act_id) { $('#calendar').fullCalendar('addEventSource', function (start, end, callback) { var startTime = Math.round($('#calendar').fullCalendar('getView').start.getTime() / 1000); var endTime = Math.round($('#calendar').fullCalendar('getView').end.getTime() / 1000); time = endTime - startTime; //alert(time); if (time &lt;= 604800) { $.ajax({ type: 'POST', url: '/Employee/GetScheduleDetailedArray/', async: false, dataType: "json", data: { // our hypothetical feed requires UNIX timestamps start: Math.round(start.getTime() / 1000), end: Math.round(end.getTime() / 1000), id: '@Model.selectedUserId', act: act_id }, success: function (doc) { callback(doc); }, error: function (xhr, status, error) { document.appendChild(xhr.responseText); } }); //end ajax } else { callback(); } }); } </code></pre> <p>The problem is I can't figure our how to assign a color to the event source when adding it this way.</p> <p><strong>====EDIT=====</strong></p> <p>Okay I found a hackish way to change the inside background color of events, I use the eventAfterRender and it's element object to compare it to a list of events that I have colors associated with. I hope this will kind of help someone until I find out a better way</p> <pre><code> $('#calendar').fullCalendar({ height: 600, width: 700, header: { right: 'prev,next today', center: 'title', left: 'month,agendaWeek,agendaDay' }, eventAfterRender: function (event, element, view) { for (x = 0; x &lt; activityColors[0].length; x++) { if (event.id == activityColors[0][x]) { element.children().css({ "background-color": "#" + activityColors[1][x] }) } } } }); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload