dev520
dev520

Reputation: 11

fullcalendar fire eventclick when click outside calendar

I have a list of event days. When I click on the event in the list I want to fire the same action like I click on calendar. My eventClick function:

eventClick: function(calEvent, jsEvent, view) {
 openEvent(calEvent);
}

Upvotes: 1

Views: 2674

Answers (1)

Krzysztof Kaźmierczak
Krzysztof Kaźmierczak

Reputation: 1434

Try this. Assign some id to your event. Then, in eventRender event, add this id to the event div. Note there is also eventClick handler present:

$('#calendar').fullCalendar({
        header: {
            left: 'prev,next today',
            center: 'title',
            right: 'month,basicWeek,basicDay'
        },
        defaultDate: '2016-09-12',
        navLinks: true, // can click day/week names to navigate views
        editable: true,
        eventLimit: true, // allow "more" link when too many events
        events: [
            {
                title: 'Meeting',
                start: '2016-09-12T10:30:00',
                end: '2016-09-12T12:30:00',
                id: "1234"
            }
        ],
        eventRender: function (event, element, view) {
            element.find('.fc-content').attr("id", "event-" + event.id);
        },
        eventClick: function (event, jsEvent, view) {
            alert(event.id);
        },
    });

Then call this after your events list click:

$('#event-1234.fc-content').trigger('click');

You can try it here:

http://jsbin.com/fejifovuxo/edit?js,output

Upvotes: 3

Related Questions