0

我正在使用来自http://arshaw.com/fullcalendar/的 Fullcalendar ,我有搜索 stackoverflow 但没有答案适合我的问题,或者我不明白。如果这已经是答案,请粘贴链接。

我有一个返回事件的 xml 文件:

事件示例:

<event allDay="false" editable="true" end="Mon Apr 29 2013 15:30:00 GMT+0100" id="53" start="Mon Apr 29 2013 08:30:00 GMT+0100" title="tesete"/>

如果您注意到开始和结束日期,时间格式就是这样保存的。

当我像这样获取事件时:

events: function(start, end, callback) {
            $.ajax({
                type: 'POST',
                url: url,
                dataType:'xml',
                crossDomain: true,
                data: {
                    // our hypothetical feed requires UNIX timestamps
                    start: Math.round(start.getTime() / 1000),
                    end: Math.round(end.getTime() / 1000),                      
                    'ajax':true,
                    'acc':'2',                      
                },
                success: function(doc) {                            
                    var events = [];
                    $(doc).find('event').each(function() 
                    {
                        events.push({
                            id: $(this).attr('id'),
                            title: $(this).attr('title'),
                            start: $(this).attr('start'),
                            end: $(this).attr('end'),
                            allDay: $(this).attr('allDay'),
                            editable: $(this).attr('editable')
                        });                             
                    });                                     
                    callback(events);
                }
            });     
        },

所有事件都正确显示在月视图中,但是当我切换到议程视图或日视图时,事件仅在 allDay 栏中,它们不会在特定时间之间呈现。

 start="Mon Apr 29 2013 08:30:00 GMT+0100" end="Mon Apr 29 2013 15:30:00 GMT+0100" id="53"

例如从 8:30 到 15:30

我错过了什么?

问题的解决方案:

events: function(start, end, callback) {
            $.ajax({
                type: 'POST',
                url: 'myurl',
                dataType:'xml',
                crossDomain: true,
                data: {
                    // our hypothetical feed requires UNIX timestamps
                    start: Math.round(start.getTime() / 1000),
                    end: Math.round(end.getTime() / 1000),                      
                    'ajax':true,
                    'acc':'2',                      
                },
                success: function(doc) {                            
                    var events = [];
                    var allday = null; //Workaround 
                    $(doc).find('event').each(function() 
                    {               

                        if($(this).attr('allDay') == "false") //Workaround 
                                allday = false; //Workaround 
                        if($(this).attr('allDay') == "true") //Workaround 
                                allday = true; //Workaround                         

                        events.push({
                            id: $(this).attr('id'),
                            title: $(this).attr('title'),
                            start: $(this).attr('start'),
                            end: $(this).attr('end'),                       
                            allDay: allday,
                            editable: $(this).attr('editable')
                        });                             
                    });                                     
                    callback(events);
                }
            });     
        },
4

1 回答 1

0

Var allDay 不能是字符串。它应该allDay=false没有引号

于 2013-04-29T11:49:16.983 回答