fullcalendar动态添加事件

fullcalendar动态添加事件

本文介绍了fullcalendar动态添加事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有:

<$ p $ fullCalendar({
viewRender:function(view){

var h;
if(view.name ==month){
h = NaN;
}
else {
h = 2500; //足够高以避免滚动条
}

$ b $('#calendar')。fullCalendar('option','contentHeight',h);
},
lang:'fr',
events:[
{
title:'8présents',
start:data [0]
},
{
标题:'8excusés',
start:data [1]
},
{
title:'8excusés',
start:'2015-01-08'
},
{
title:'8présents' ,
start:'2015-01-08'
},
],
dayClick:function(date,jsEvent,view){
window.location.replace (Routing.generate('dateChoisie',{date:date.format()}));
}
})

我有一个var数据,它是一个数组包含事件的所有日期。我想以同样的方式插入数据[0],数据[1]等,但动态地为所有日期插入事件。



我有试图为做一个

  events:[
for(var i = 0,max = data.Lenght; i {
title:'8présents',
start:data [i]



标题:'8excusés',
start:data [1]
},
{
title :'8excusés',
start:'2015-01-08'
},
{
title:'8présents',
start:'2015- 01-08'
},
],

但它在列表中不起作用。



任何人都知道我能做到这一点吗? 解析方案

您可以动态添加事件。

  var event = {id:1,title:'New event',start:new Date )}; 

$('#calendar')。fullCalendar('renderEvent',event,true);


I'm trying to create events in my full calendar dynamically.

I have:

$('#calendar').fullCalendar({
                viewRender: function (view) {

                    var h;
                    if (view.name == "month") {
                        h = NaN;
                    }
                    else {
                        h = 2500; // high enough to avoid scrollbars
                    }


                    $('#calendar').fullCalendar('option', 'contentHeight', h);
                },
                lang: 'fr',
                events: [
                    {
                        title: '8 présents',
                        start: data[0]
                    },
                    {
                        title: '8 excusés',
                        start: data[1]
                    },
                    {
                        title: '8 excusés',
                        start: '2015-01-08'
                    },
                    {
                        title: '8 présents',
                        start: '2015-01-08'
                    },
                ],
                dayClick: function (date, jsEvent, view) {
                    window.location.replace(Routing.generate('dateChoisie', {date: date.format()}));
                }
            })

I have a var data, which is an array that contains all the dates of the events. I want to insert this in the events in the same way I inserted data[0], data[1], etc, but dynamically for all the dates.

I have tried to do a for:

events: [
    for (var i = 0, max = data.Lenght; i < max; i++) {
         {
                 title: '8 présents',
                 start: data[i]
           },
    }
                                {
                                    title: '8 excusés',
                                    start: data[1]
                                },
                                {
                                    title: '8 excusés',
                                    start: '2015-01-08'
                                },
                                {
                                    title: '8 présents',
                                    start: '2015-01-08'
                                },
                            ],

But it doesn't work inside the list.

Anybody know how I can do this?

解决方案

after rendering the full calendar you can add events dynamically.

var event={id:1 , title: 'New event', start:  new Date()};

$('#calendar').fullCalendar( 'renderEvent', event, true);

这篇关于fullcalendar动态添加事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-29 12:17