fullcalendar fire eventclick when click outside calendar

前端 未结 1 1858
旧巷少年郎
旧巷少年郎 2021-01-27 16:53

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:          


        
1条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-27 17:28

    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

    0 讨论(0)
提交回复
热议问题