2
I have a list of teachers, within each teacher, I have a sublist of subjects. I need to create something like a "weekly calendar" for every time I select a teacher, I show his subjects on the weekly calendar (so I know the day / duration of the course).
Well, I’m trying to use Fullcalendar. Here’s my code:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Calendario</title>
<script src='calendario/lib/moment.min.js'></script>
<script src='calendario/fullcalendar.js'></script>
<script src='calendario/lang/pt-br.js'></script>
<link rel='stylesheet' href='calendario/fullcalendar.css'/>
<script type="text/javascript">
$(document).ready(function(){
var date = new Date();
var dia = date.getDate();
var m = date.getMonth()+1; //January is 0
var mes = m < 10 ? '0' + m : '' + m;
var ano = date.getFullYear();
var data = ano + '-' + mes + '-' + dia;
//Page is now ready, initialize calenda.
$('#calendario').fullCalendar({
header: {
center: 'title',
left: '',
right: ''
},
height: 800,
defaultView: 'agendaWeek',
views: {
week: {
columnFormat: 'dddd'
}
},
firstDay: 1,
weekends: false,
events: [
{
title: 'Event1',
start: ano + '-' + mes + '-' + dia,
end: ano + '-' + mes + '-' + dia + 'T04:00'
}
],
})
});
</script>
</head>
<body>
<div class="teste">
<div id="calendario"></div>
</div>
</body>
</html>
As you can see, I’m adding the events
manually inside the header. I wonder how I can do this dynamically ? (Or, advice from another more appropriate tool).
I have an event that I
toggle
in the menu, to open and show the submenu (accordion effect). Adding this code snippet there is to work well ?– PlayHardGoPro
Yes, you can put it anywhere. See how it works http://codepen.io/anon/pen/EKwPXo
– rodorgas
Excellent ! Last thing, you can make the plugin accept date in dd/mm/yyyy format ?
– PlayHardGoPro
fi can do everything, since the project is opensource, but natively it only accepts some specific formats even. edited my reply showing how to do the conversion using Moment.
– rodorgas