简体   繁体   English

jQuery FullCalendar通过jQuery Events获取事件ID

[英]Jquery FullCalendar get event id by jquery events

I'm using FullCalendar plugin in order to show daily calendar. 我正在使用FullCalendar插件以显示每日日历。 When the user clicks on an event I want to get the calendar event id. 当用户单击事件时,我想获取日历事件ID。 I did that by the FullCalendar click event: 我是通过FullCalendar点击事件来做到这一点的:

$('#calendar').fullCalendar({
    ...
    eventClick: function(calEvent, jsEvent, View)
    {
        console.log(calEvent.id);    
    }
});

I want to get the same event id by using JQuery events: 我想通过使用JQuery事件获得相同的事件ID:

$('.fc-event').on('click', function(){
    console.log(...) //How do I get the the FullCalendar event id?
});

I'm very flexible in what way to do that - Get the id from the .fc-content with JQuery or bind some id in the events themselves and then show it when needed. 我以哪种方式非常灵活-使用JQuery从.fc-content获取ID或在事件本身中绑定一些ID,然后在需要时显示它。

Thanks a lot! 非常感谢!

I found a solution to my problem. 我找到了解决问题的方法。 Bind the id when the calendar events are rendered: 呈现日历事件时绑定ID:

$('#calendar').fullCalendar({
    ...
    eventRender: function(event, element)
    {
        element.find('.fc-content').attr("id", event.id);    
    }
});

And then you can use JQuery events by the id attr 然后您可以通过id attr使用JQuery事件

$('.fc-content').on('dblclick', function(){
    console.log($(this).attr("id"));
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM