开发者

JQuery Full Calendar eventClick issue, appending DateTime to calEvent.url asp.net mvc 3

I'm having trouble appending the date to the calEvent.Url. The same thing works fine in in the dayClick, but when I try and append the same code to the calEvent.Url my events dissappear from the calendar. I have a route set up in Global.asax to handle the urls and direct them to the correct action. This is working fine on the dayClick, but not the event click. Any help is greatly appreciated!

<script type="text/javascript">
$(document).ready(function () {
    $('#calendar').fullCalendar({
        theme: false,
        header: {
            left: 'prev,next today',
            center: 'title',
            right: 'agendaDay, agendaWeek, month'

        },

        defaultView: 'month',
        editable: false,
        allDay: true,
        eventClick: function (calEvent, jsEvent, view) {

            window.location.href = 'BrowseCal/' +
                 date.getDate() + '-' +
                    (date.getMonth() + 1) + '-' + // months are zero based
                         date.getFullYear();

            // change the border color just for fun
            $(this).css('border-color', 'red');

        },
        dayClick: function (date, allDay, jsEvent, view) {

            if (allDay) {

                window.location.href = 'BrowseCal/' +
                 date.getDate() + '-' +
                    (date.getMonth() + 1) + '-' + // months are zero based
                         date.getFullYear();


            }

        },

        events: function (start, end, callback, date) {
            // do some asynchronous ajax
            contentType: "application/json; charset=utf-8",
            $.getJSON("/WhatsOn/CalendarData/",

                function (result, date) {
                    if (result != null) {
                        for (i in result) {
                            var calEvent = result[i];

                            calEvent.start = new Date(parseInt(calEvent.start.replace("/Date(", "").replace(")/", ""), 10));
                            calEvent.end = new Date(parseInt(calEvent.end.replace("/Date(", "").replace(")/", ""), 10));
开发者_如何学运维
                            **calEvent.Url = 'BrowseCal/' + date.getDate() + '-' + (date.getMonth() + 1) + '-' + date.getFullTear();**


                        }
                    }

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


                });


        }

    });
});


Well, it seems that date isn't defined where you've marked your code with *. Are you sure you don't want start.getDate(), start.getMonth() etc, either that or end.getDate() and so on..

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜