jQuery的完整的日历没有显示事件 [英] jquery Full Calendar not showing events

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

问题描述

我使用asp.net的MVC列出了jQuery的完整的日历事件。下面是我使用列出从通过JSON MVC事件的脚本。

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天全站免登陆