簡體   English   中英

Fullcalender下一個和上一個在MVC4中進行更多函數調用

[英]Fullcalender next and previous make more function call in MVC4

我已經嘗試過用Fullcalender.js和Moment()在jquery中編寫代碼。

  $(document).ready(function () {    
    var CalLoading = true;
    $('#calendar').fullCalendar({
        header: {
            left: 'prev,next today',
            center: 'title',
            right: 'month,agendaWeek,agendaDay'
        },
        defaultView: 'month',
        defaultDate:moment(),
        editable: true,
        allDaySlot: false,
        selectable: true,
        slotMinutes: 15,
        events:  function (start, end, callback) {
               $.getJSON("@Url.Action("EventSummary")", function (locationsArray) {
                   var result = $(locationsArray).map(function () {
                       return {
                           title: this.title,
                           start: this.start,
                           end: this.end,
                           allDay: this.editable
                       };
                   }).toArray();
                   callback(result);
               });
           },
        eventClick: function (calEvent, jsEvent, view) {
            alert('You clicked on event id: ' + calEvent.id
                + "\nSpecial ID: " + calEvent.someKey
                + "\nAnd the title is: " + calEvent.title);

        },

        eventDrop: function (event, dayDelta, minuteDelta, allDay, revertFunc) {
            if (confirm("Confirm move?")) {
                UpdateEvent(event.id, event.start);
            }
            else {
                revertFunc();
            }
        },

        eventResize: function (event, dayDelta, minuteDelta, revertFunc) {

            if (confirm("Confirm change appointment length?")) {
                UpdateEvent(event.id, event.start, event.end);
            }
            else {
                revertFunc();
            }
        },



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

            $('#eventTitle').val("");
            $('#eventDate').val(moment(date).format('DD/MM/YYYY'));
            $('#eventTime').val(moment(date).format('HH:mm'));
            ShowEventPopup(date);
        },

        viewRender: function (view, element) {

            if (!CalLoading) {
                if (view.name == 'month') {
                    $('#calendar').fullCalendar('removeEventSource', sourceFullView);
                    $('#calendar').fullCalendar('removeEvents');
                    $('#calendar').fullCalendar('addEventSource', sourceSummaryView);
                }
                else {
                    $('#calendar').fullCalendar('removeEventSource', sourceSummaryView);
                    $('#calendar').fullCalendar('removeEvents');
                    $('#calendar').fullCalendar('addEventSource', sourceFullView);
                }
            }
        }

    });

    CalLoading = false;


});

它具有調用prev的功能,每次點擊都會使調用增加兩次

Hai @Saneesh試試這個...

events: function (start, end, timezone, callback) {
 $.ajax({
                        url : '@Url.Action("GetEvents","FullCalender")',
                        dataType: "json",
                        data: {
                            start: start.unix(),
                            end: end.unix()
                        },
                        success: function (doc) {
                                var events = [];
                                $.each(doc, function (i, item) {
                                //alert(item["title"]);
                                    events.push({
                                             title: $(this).attr('title'),
                                             start: $(this).attr('start'), // will be parsed
                                             end: $(this).attr('end')
                                           });
                                     });
                                        callback(events);
                               }
                    });
                }

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM