4

In FullCalendar how can I make a resource clickable?

I've checked the API but I cannot see anything about that, am I missing something?

I'm after a resource-click-event as we have for events?

lokusking
  • 7,396
  • 13
  • 38
  • 57
TZAU
  • 53
  • 2
  • 6

2 Answers2

4

In the resourceRender callback function you can add a click handler to the second argument.

function resourceRenderCallback(resourceObj, labelTds, bodyTds){
    labelTds.on('click', function(){console.log('click');});
}

This is obviously a very minimal function for the click but you can fill in that function with whatever you need. To match the docs more this would be closer to how they define the function

resourceRender: function(resourceObj, labelTds, bodyTds) {
    labelTds.on('click', function(){console.log('click');});
}
Daffy13
  • 519
  • 10
  • 21
3

This has since changed in version Full Calendar Resource Timeline Schedular version 4.0. You have to use 'addEventListener' to the DOM object 'el' See the below snippet calling 'resourceRender'.

document.addEventListener('DOMContentLoaded', function () {
        var calendarEl = document.getElementById('calendar');
        var calendar = new FullCalendar.Calendar(calendarEl, {
            schedulerLicenseKey: '<hidden>',
            plugins: ['interaction', 'resourceTimeline'],
            resourceLabelText: 'Resources',
            resources: "<see fullcalendar support docs>",
            events: "<see fullcalendar support docs>",
            resourceRender: function (renderInfo) {
                renderInfo.el.addEventListener("click", function () { console.log('clicked:' + renderInfo.resource.id); });
            }
        });
        calendar.render();
    });
moto_geek
  • 510
  • 5
  • 14