完整日历更新事件和新事件ajax调用



嗨,伙计们,我没有什么问题。我设置了我的Fullcalendar,与数据库连接,所有显示都很好,现在我在更新和添加新事件方面没有什么问题(24小时格式和全天:错误

而不是警报(event.id+'已移动'+delta+'天\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 + ' daysn' +
                '(should probably update your database)');
        },
        timeFormat: 'H:mm',
        loading: function (bool) {
            if (bool) $('#loading').show();
            else $('#loading').hide();
        }
    });
});

只需在事件处理程序中使用记录良好的jQueryAjax函数!

    eventDrop: function (event, dayDelta, minuteDelta) {
        // message to end user
        alert(event.id + ' was moved ' + dayDelta + ' daysn' +
            '- database will be updated now');
        /**
         * perform ajax call for db update
         */            
        jQuery.post(
            'createevent.php'
            , { 
                id: event.id
                , start: event.start
                , end: event.end
            }
        );                    
    }

您还应该查看fullcalendars拖放回调的文档

最新更新