jquery完整日历不显示事件

时间:2009-10-09 14:07:56

标签: jquery asp.net-mvc json calendar fullcalendar

我正在使用asp.net mvc列出jquery完整日历中的事件。下面是我用来通过mvc中的json列出事件的脚本。

$('#calendar').fullCalendar({
        theme: true,
        editable: true,
        disableDragging: true,
        disableResizing: true,
        header: {
            left: 'prev,next today',
            center: 'title',
            right: 'month,basicWeek,basicDay'
        },
        events: function(start, end, callback) {
        // do some asynchronous ajax
        $.getJSON("/User/GetEvents/",
            {
                    start: dateFormat(start.getTime()),
                    end: dateFormat(end.getTime())
            },
            function(result) {
                    // then, pass the CalEvent array to the callback
                    callback(result);
            })
        },
        eventClick : function(event) {
            editEventShow(event);
        },
        dayClick : function(dayDate){
            addEventShow(dayDate, this);
        }
    });

但上面的脚本没有在日历中显示任何事件。我在上面的脚本中做错了什么?

2 个答案:

答案 0 :(得分:4)

当我从json中将事件的日期解析为:

时,它已经解决了
events: function(start, end, callback) {
            // do some asynchronous ajax
            contentType:"application/json; charset=utf-8",
            $.getJSON("/User/GetEvents/",
                    {
                            start: dateFormat(start.getTime()),
                            end: dateFormat(end.getTime())
                    },
                    function(result) {
                            if(result != null)
                            {
                                for (i in result) {
                                    var calEvent = result[i];
                                    calEvent.date = new Date(parseInt(calEvent.date.replace("/Date(", "").replace(")/", ""), 10));
                                    calEvent.start = new Date(parseInt(calEvent.start.replace("/Date(", "").replace(")/", ""), 10));
                                    calEvent.end = new Date(parseInt(calEvent.end.replace("/Date(", "").replace(")/", ""), 10));
                                }
                            }

                            var calevents = result;
                            // then, pass the CalEvent array to the callback
                            callback(calevents);

                    });

        },

答案 1 :(得分:1)

您还可以使用

格式化服务器端的日期字符串
DateTime.Now.ToString("s"):

请参阅:http://weblogs.asp.net/gunnarpeipman/archive/2010/02/03/using-fullcalendar-jquery-component-with-asp-net-mvc.aspx

相关问题