javascript 在 fullcalendar 中添加有关事件的更多信息

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8663607/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-26 04:10:00  来源:igfitidea点击:

Add more info about event in fullcalendar

javascriptjqueryfullcalendar

提问by trta

How can I add more information to a specific view?

如何向特定视图添加更多信息?

I want to display more info about my events with the dayAgenda view from my mysql table (the values that are already stored into the array coming from my json-events.php).

我想通过我的 mysql 表中的 dayAgenda 视图显示有关我的事件的更多信息(已经存储到来自我的 json-events.php 的数组中的值)。

I read the documentation of the fullcalendar, especially about eventRender, but I do not understand the explanation of the code.

我阅读了 fullcalendar 的文档,尤其是关于 eventRender 的文档,但我不明白代码的解释。

Please, how can I do that? Thanks.

请问,我该怎么做?谢谢。

采纳答案by Juan Gonzales

Know that anywhere you can call an "event object" you can call any of the fields you desire from your array. AKA.

知道在任何可以调用“事件对象”的地方,都可以调用数组中所需的任何字段。又名。

eventRender: function(event){
    var description = event.description; 
    var firstname = event.firstname;} //or
eventMouseover: function(event){
    var description = event.description; 
    var lastname = event.lastname;} // or
eventResize(event): function(event){
    var description = event.description; 
    var place = event.place;} // you get the picture...

Also you can specify a specific view by using...

您也可以使用...

var view = calendar.fullCalendar('getView');
if(view.name === "agendaDay"){
    // do something
}

or by using some of the built in view objects inside the callbacks like...

或者通过在回调中使用一些内置的视图对象,例如......

eventRender: function(event, element, view){
    if(view.name === "agendaDay"){
        // do something
    }
}

回答by Andrew Whitaker

You can provide your own rendering logic using the eventRendercallback:

您可以使用eventRender回调提供自己的渲染逻辑:

eventRender: function(event, element, view) {
    if (view.name === "agendaDay") {
        element.find(".fc-event-content")
            .append("<b>Description</b>:" + event.description);
    }
}

Where descriptionis one of your custom event properties. You may have to change your rendering logic depending on the view the person is currently on.

description您的自定义事件属性之一在哪里。您可能需要根据用户当前所在的视图更改渲染逻辑。

Example:http://jsfiddle.net/LjCV9/(click the Daybutton on the top right of the calendar)

示例:http : //jsfiddle.net/LjCV9/(点击日历右上角的按钮)

回答by gjijon

For newer versions:

对于较新的版本:

$('#calendar').fullCalendar({
eventRender: function (objEvent, element, view) {
    if (view.name === "agendaDay") { //or agendaWeek
        element.find(".fc-content")
                .append("<b>Other Info</b>:<br/>" + objEvent.otherInfo);
    }
} });