简体   繁体   English

Fullcalendar更新事件和新事件ajax调用

[英]Fullcalendar update event and new event ajax call

Hy guys, I have little problem. 大家好,我没什么问题。 I was setup my Fullcalendar, connect with database and all showing good, now i have little problem with update and add new event (in 24 hours format and allday:false 我已经设置了Fullcalendar,与数据库连接,并且一切都很好,现在我几乎没有更新和添加新事件的问题了(以24小时格式,整天都是:false

Instead of alert(event.id + ' was moved ' + delta + ' days\\n' + '(should probably update your database)'); 而不是alert(event.id +'已移动'+ delta +'days \\ n'+'(可能应该更新您的数据库)'); i need calling to my createevent.php?id=$id&start=$star&end=$end 我需要致电我的createevent.php?id = $ id&start = $ star&end = $ end

My json: 我的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}]

Also i need this for creating new event, i was put selectable jQuery and then work (input dialog). 我也需要这个来创建新事件,我将其放置在可选择的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();
        }

    });

});

Just use well documented jQuery Ajax functions within the event handler ! 只需在事件处理程序中使用记录良好的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
            }
        );                    
    }

You should also take a look at the docu of fullcalendars drag/drop callbacks 您还应该看看fullcalendars拖放回调的文档

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM