In controller
------------------
def home():
rows = db(db.cal_events).select()
return dict(rows=rows)
In view
------------
<script type="text/javascript">
$(document).ready(function() {
$('#calendar').fullCalendar({
aspectRatio: 0.7,
fixedWeekCount: false,
height: "auto",
contentHeight: "auto",
events: [
{{for i,row in enumerate(rows):}}{{if i!=0:}},{{pass}}
{
tip: '{{=row.title}}',
title: '{{=row.title}}',
allDay: false,
start: new Date('{{=row.start_date}}'),
end: new Date('{{=row.end_date}}')
}
{{pass}}
],
eventRender: function(event, element,view) {
if(event.start._d.getMonth() !== $('#calendar').fullCalendar('getDate')._d.getMonth()) {
return false; // thanks jettpleyn
http://stackoverflow.com/questions/7628040/remove-past-dates-and-next-months-dates-from-the-current-month }
element.attr('title', event.tip);
},
dayRender: function (moment, cell) {
/*var m = moment();*/
var day_of_the_week = moment.day();
if (day_of_the_week == 0)
cell.css("background-color", "yellow");
else
cell.css("background-color", "linen");
{{for i,row in enumerate(rows):}}
{{if row.lv_type == 'PH':}}
/*cell.css("background-color","yellow");*/
$('.fc-day[data-date="' + '{{=row.start_date}}' + '"]').css('background-color', 'turquoise');
{{pass}}
{{if row.lv_type == 'AH':}}
$('.fc-day[data-date="' + '{{=row.start_date}}' + '"]').css('background-color', '#FF8C8D');
{{pass}}
{{if row.lv_type == 'RH':}}
$('.fc-day[data-date="' + '{{=row.start_date}}' + '"]').css('background-color', '#FF8C8E');
{{pass}}
{{if row.lv_type == 'SS':}}
$('.fc-day[data-date="' + '{{=row.start_date}}' + '"]').css('background-color', 'silver');
{{pass}}
/*$('td[data-date="' + '{{=row.start_date}}' + '"]').addClass('fully_colored_holiday');*/
$('.fc-other-month').html('');
$('.fc-other-month').css("background-color", "linen");
{{pass}}
}
})
});
</script>
Thats all.