fullcalendar fire eventclick when click outside calendar

廉价感情. 提交于 2019-12-25 07:30:34

问题


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);
}

回答1:


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

Good luck!



来源:https://stackoverflow.com/questions/39382690/fullcalendar-fire-eventclick-when-click-outside-calendar

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!