Pregunta

Estoy utilizando asp.net mvc para listar los eventos en el calendario lleno jQuery. A continuación se muestra la secuencia de comandos que estoy utilizando para listar los eventos a través de JSON de 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);
        }
    });

Pero el guión anterior no muestra ningún evento en el calendario. ¿Qué estoy haciendo mal en el guión anterior?

¿Fue útil?

Solución

Se ha solucionado cuando Analizada la fecha a partir de los acontecimientos de JSON como:

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

                    });

        },

Otros consejos

También puede dar formato a la cadena de fecha en el lado del servidor con

DateTime.Now.ToString("s"):

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

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top