Reputation: 21440
I am loading tooltips on my events; however, the tooltips don't seem to work inside of the "eventLimit" popover.
I have tried re-initializing the tooltips on the click event, but the click event occurs before whereas I need to re-initialize the tooltips after.
Is there an after or some other event I can wire into?
// tried this but it doesn't work...
eventLimitClick: function () {
$('[data-toggle="tooltip"]').tooltip({ container: 'body', html: true }); // re-init tooltips
return "popover";
},
Codepen example: https://codepen.io/anon/pen/xWLKeK?editors=0110
Full-code (for reference):
$(function() {
$('#calendar').fullCalendar({
defaultView: 'month',
defaultDate: '2018-03-07',
header: {
left: 'prev,next',
center: 'title',
right: 'month,agendaWeek,agendaDay'
},
eventRender: function (event, element) {
element
.attr('title', event.title)
.attr('data-placement', 'bottom')
.attr('data-toggle', 'tooltip');
},
eventLimit: 2, // allow "more" link when too many events
eventAfterAllRender: function () {
$('[data-toggle="tooltip"]').tooltip({ container: 'body', html: true });
},
// tried this but it doesn't work...
eventLimitClick: function () {
$('[data-toggle="tooltip"]').tooltip({ container: 'body', html: true }); // re-init tooltips
return "popover";
},
events: [
{
title: 'All Day Event',
start: '2018-03-01'
},
{
title: 'Long Event',
start: '2018-03-07',
end: '2018-03-10'
},
{
id: 999,
title: 'Repeating Event',
start: '2018-03-09T16:00:00'
},
{
id: 999,
title: 'Repeating Event',
start: '2018-03-16T16:00:00'
},
{
title: 'Conference',
start: '2018-03-11',
end: '2018-03-13'
},
{
title: 'Meeting',
start: '2018-03-12T10:30:00',
end: '2018-03-12T12:30:00'
},
{
title: 'Lunch',
start: '2018-03-12T12:00:00'
},
{
title: 'Meeting',
start: '2018-03-12T14:30:00'
},
{
title: 'Birthday Party',
start: '2018-03-13T07:00:00'
},
{
title: 'Click for Google',
url: 'http://google.com/',
start: '2018-03-28'
}
]
});
});
Upvotes: 0
Views: 1797
Reputation: 71
Why do you want to set the data-toggle attribute in eventRender
element.attr('data-toggle', 'tooltip')
then use the generic mecanism in eventAfterAllRender
$('[data-toggle="tooltip"]').tooltip(...)
rather than just do directly in eventRender
$(element).tooltip(...)
(More of a question actually, since I am not used to bootstrap.js which seems to be what you are using).
Upvotes: 2
Reputation: 21440
My solution was to watch for .fc-popovers
inserted into the .fc-view
and re-init the tooltips there:
viewRender: function(view, element) {
// add handler to watch items inserted into .fc-view to catch popovers and re-init tooltips
$('.fc-view').on('DOMNodeInserted', function (e) {
if ($(e.target).hasClass('fc-popover')) {
$('[data-toggle="tooltip"]').tooltip({ container: 'body', html: true }); // re-init tooltips
}
});
},
Codepen example: https://codepen.io/anon/pen/MVvaLY?editors=0110
Upvotes: 1