如何只将eventSources放入FullCalendar中?

时间:2011-05-10 11:04:23

标签: jquery fullcalendar

我使用FullCalendar,我使用eventSources和ajax调用我的事件,如下所示:

eventSources: 
        [
            {
                url: 'ajax.php',
                type: 'POST',
                data: {
                   obj: 'Event'
                },
                error: function() {
                    alert('there was an error while fetching events!');
                }

            },          
        ],

Return JSON代码如下所示:

[{"id":"1","name":"Event One","town":"London","start":"2011-05-10","url":"","title":"Event One","className":"Event_class","description":"Hier some description","color":"#D42993","draggable":"false"},{another Events}]

到目前为止一切都很好,然后我试图制作那些事件Droppable(而不是日历),以便我可以将外部对象拖入其中(例如“经理”)。

我以这种方式更改了eventSources,但它不起作用:

eventSources: 
        [
            {
                url: 'ajax.php',
                type: 'POST',
                data: {
                   obj: 'Event'
                },
                error: function() {
                    alert('there was an error while fetching events!');
                },
                textColor: 'black',
                                    disableDragging: true,
                cache: true,
                                    dropAccept: '.Personal',
                droppable : true,
                                    eventDrop: function(e, ui){ alert("drop")}
            },          
        ],

有人可以帮助我吗?谢谢!

1 个答案:

答案 0 :(得分:1)

我找到了!只需像这样使用eventRender:

eventSources: 
        [
            {
                url: 'ajax.php',
                type: 'POST',
                ...
                                    dropAccept: '.myClass',//class of my external elts
                droppable : true
            },          
        ],
    droppable: false, //make the rest of our Calendar not droppable  
eventRender: 
        function(event, element) {//Our events -> from eventSources
                            element.droppable({//make only my events droppable
                                accept: '.myClass',//my external elts
                                activeClass: 'droppable-active',
                                hoverClass: 'droppable-hover',
                                drop: function(e, ui){ }//Actions
                             })               
        }