Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get Id and title from background events on dayClick

$('#calendar').fullCalendar({
        header: 
        {
            left: 'prev,next today',
            center: 'title',
            right: 'agendaWeek,agendaDay'
        },
        events: [
                {
                    id: 'availableForMeeting',
                    start: '2015-02-11T10:00:00',
                    end: '2015-02-11T16:00:00',
                    rendering: 'background'
                },
                {
                    id: 'availableForMeeting',
                    start: '2015-02-13T10:00:00',
                    end: '2015-02-13T16:00:00',
                    rendering: 'background'
                }
        ]
        dayClick: 
        function(date, jsEvent, view) {
            if (jsEvent.target.classList.contains('fc-bgevent')) {
                //I can find out if it is a backround event.                
            }
        }
    }); 

I can find out if it is a backround event but how can I get the id of it?

like image 225
Phil Avatar asked Nov 22 '25 00:11

Phil


1 Answers

Combine dayClick with the eventRender callback.

eventRender: function(event,element){
    if(event.rendering == "background"){
        element.data(event); //store the event data inside the element
    }
},
dayClick: function(date, jsEvent) {
    if (jsEvent.target.classList.contains('fc-bgevent')) {
        console.log($(jsEvent.target).data());
    }
},

JSFiddle

like image 150
DanielST Avatar answered Nov 24 '25 14:11

DanielST



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!