jquery完整日历不显示事件 [英] jquery Full Calendar not showing events

查看:46
本文介绍了jquery完整日历不显示事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am using asp.net mvc to list the events in the jquery full calendar. Below is the script i am using to list the events through json from mvc.

$('#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);
        }
    });

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

But the above script not showing any events in the calendar. What am i doing wrong in the above script?

推荐答案

当我从json中的事件中解析日期时已经解决了:

It has been solved when i parsed the date from the events from json as:

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);

                    });

        },

这篇关于jquery完整日历不显示事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆