Tooltip error
HTML
<link rel="stylesheet" href="https://fullcalendar.io/js/fullcalendar-3.0.0/fullcalendar.css">
<script data-require="[email protected]" data-semver="3.1.0" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.0/jquery.js"></script>
<script data-require="[email protected]" data-semver="2.14.1" src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.14.1/moment.js"></script>
<script data-require="[email protected]" data-semver="3.0.0" src="https://cdnjs.cloudflare.com/ajax/libs/fullcalendar/3.0.0/fullcalendar.js"></script>
<script>
var events = [
{
title: 'All Day Event',
start: '2016-12-01'
},
{
title: 'Long Event',
start: '2016-12-07',
end: '2016-12-10'
},
{
id: 999,
title: 'Repeating Event',
start: '2016-12-09T16:00:00'
},
{
id: 999,
title: 'Repeating Event',
start: '2016-12-16T16:00:00'
},
{
title: 'Conference',
start: '2016-12-11',
end: '2016-12-13'
},
{
title: 'Meeting',
start: '2016-12-12T10:30:00',
end: '2016-12-12T12:30:00'
},
{
title: 'Lunch',
start: '2016-12-12T12:00:00'
},
{
title: 'Meeting',
start: '2016-12-12T14:30:00'
},
{
title: 'Happy Hour',
start: '2016-12-12T17:30:00'
},
{
title: 'Dinner',
start: '2016-12-12T20:00:00'
},
{
title: 'Birthday Party',
start: '2016-12-13T07:00:00'
},
{
title: 'Click for Google',
url: 'http://google.com/',
start: '2016-12-28'
}
];
</script>
<div id='calendar'></div>
JavaScript
$(document).ready(function() {
$('#calendar').fullCalendar({
header: {
left: '',
center: 'title',
right: ''
},
minTime: '07:00:00',
maxTime: '18:30:00',
businessHours: true,
allDaySlot: false,
defaultView: 'month',
defaultDate: '2016-12-12',
navLinks: true, // can click day/week names to navigate views
editable: true,
eventLimit: true, // allow "more" link when too many events
viewRender: activateToolTip,
events: events
});
function activateToolTip(view) {
if (view.name == 'agendaWeek') {
var tip = $('<span id="tip"></span>');
$timeSlot = $('#calendar').find('.fc-body');
$timeSlot.on('mouseenter', '.fc-slats tr td', function(e) {
var time = $(e.target.parentNode).attr('data-time');
if (time) { // "07:45:00"
time = time.split(':').slice(0, -1).join(':'); // "07:45"
tip.html(time).appendTo('body').show();
}
});
$timeSlot.on('mouseleave', '.fc-slats tr td', function() {
tip.hide().remove();
});
$timeSlot.on('mousemove', '.fc-slats tr td', function(e) {
tip.css({
'top': (e.pageY - 35) + 'px',
'left': (e.pageX + 10) + 'px',
'position': 'absolute',
'z-index': '2',
'font-size': '.9em',
'font-weight': 'bold',
'padding': '5px 10px',
'border-radius': '3px',
'box-shadow': '0 1px 2px grey',
'background': 'whitesmoke',
});
});
}
}
});