show.html.erb 580 Bytes
Newer Older
Zac Wood's avatar
Zac Wood committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<div id="calendar"></div>

<template id="events" data-events="<%= @events.to_json %>"></template>

<script>
 /* const cal = document.querySelector('#calendar');
  * var calendar = new Calendar(cal, {
  *     defaultView: 'agendaWeek'
  * }); */ 
 document.addEventListener('DOMContentLoaded', () => {
     const eventsJSON = document.querySelector('#events').dataset.events;
     const events = JSON.parse(eventsJSON);
     console.log(events);
     $('#calendar').fullCalendar({
	 defaultView: 'agendaWeek',
	 header: { right: 'next'},
	 events: events
     });
 });
 
</script>