-1

嗨,伙计们,我有一点问题。我正在设置我的 Fullcalendar,与数据库连接并且一切都显示良好,现在我在更新和添加新事件方面没有什么问题(以 24 小时格式和 allday:false

而不是 alert(event.id + ' wasmoved ' + delta + ' days\n' + '(应该可能更新你的数据库)'); 我需要调用我的 createevent.php?id=$id&start=$star&end=$end

我的json:

[{"id":"2","title":"hair cut Mike","start":"2013-02-02T13:30:00+01:00","end":"2013-02-02T15:30:00+01:00","color":"blue","allDay":false},{"id":"1","title":"hair cut Steve","start":"2013-02-02T09:30:00+01:00","end":"2013-02-02T10:30:00+01:00","color":"red","allDay":false}]

我也需要这个来创建新事件,我被放置了可选择的 jQuery,然后工作(输入对话框)。

<script type='text/javascript'>
$(document).ready(function () {

    $('#calendar').fullCalendar({
        header: {
            left: 'prev,next today',
            center: 'title',
            right: 'month,agendaWeek,agendaDay'
        },
        editable: true,


        allDaySlot: true,
        allDayText: 'Volledige dag',
        firstHour: 8,
        slotMinutes: 30,
        defaultEventMinutes: 120,
        axisFormat: 'HH:mm',
        timeFormat: {
            agenda: 'H:mm{ - h:mm}'
        },
        dragOpacity: {
            agenda: .5
        },
        minTime: 0,
        maxTime: 24,

        selectable: true,
        selectHelper: true,
        select: function (start, end, allDay) {
            var title = prompt('Event Title:');
            if (title) {
                calendar.fullCalendar('renderEvent', {
                    title: title,
                    start: start,
                    end: end,
                    allDay: false
                },
                true // make the event "stick"

                );
            }
            calendar.fullCalendar('unselect');


        },


        events: "json-events.php",

        eventDrop: function (event, delta) {
            alert(event.id + ' was moved ' + delta + ' days\n' +
                '(should probably update your database)');
        },
        timeFormat: 'H:mm',

        loading: function (bool) {
            if (bool) $('#loading').show();
            else $('#loading').hide();
        }

    });

});

4

1 回答 1

2

只需在事件处理程序中使用有据可查的jQuery Ajax 函数!

    eventDrop: function (event, dayDelta, minuteDelta) {
        // message to end user
        alert(event.id + ' was moved ' + dayDelta + ' days\n' +
            '- database will be updated now');

        /**
         * perform ajax call for db update
         */            
        jQuery.post(
            'createevent.php'
            , { 
                id: event.id
                , start: event.start
                , end: event.end
            }
        );                    
    }

您还应该查看完整日历拖放回调的文档

于 2013-02-15T09:47:35.603 回答