Adding iCalendar or ics export to fullcalendar — Sales Igniter rental booking software article

Adding iCalendar or ics export to fullcalendar

In Version 1.4 we have added an export to iCalendar format for our rental calendars in the admin.

There is a great script here: https://github.com/nwcell/ics.js that makes it easy to add ics export from fullcalendar, or whatever calendar system you are using. Here is some quick sample code:

<div id="calendar">&nbsp;</div>
<script><br />
// First include jquery, fullcalendar, and ics.js and ics dependencies file from their github
// JSON calendar event sample
$eventsJSON = [ {
title: 'Event Title Sample',
start: '2015-07-22',
end: '2015-07-22',
description: 'description of calendar event'
}];
// basic fullcalendar code
$('#calendar').fullCalendar({
defaultDate: new Date(y, m, d),
editable: false,
events: $eventsJSON
});
// setup ics
var cal = ics();
// go through each event from the json and add an event for it to ics
$.each($eventsJSON,function(i,$event){
cal.addEvent($event.title, $event.description, '', $event.start, $event.end);
});
// Download iCal button onclick listener
$("#icaldownload").on('click',function(){
cal.download('ical','.ics');
});
</script>
<button id="icaldownload" style="float: right; margin-bottom: 10px;">Download iCal</button>