调整大小后,jQuery fullcalendar不会更新数据库

时间:2017-07-01 12:57:15

标签: jquery resize save fullcalendar

奥拉,

我在数据库中存储了一些事件,并在我的jquery fullcalendar中显示了这些事件。现在我也让它工作,这样我就可以通过拖放来改变活动的那一天。通过调整事件的大小来改变时间,我无法正常工作。

我想这与我没有时间在一起有关:

start = moment(start, 'DD.MM.YYYY').format('YYYY-MM-DD')
end = moment(end, 'DD.MM.YYYY').format('YYYY-MM-DD')

但我尝试的所有格式(例如:YYYY-MM-DDThh:mm:ss)都会出现此错误:

Uncaught ReferenceError: start is not defined

现在使用我当前的代码可以调整元素大小,它只会将它们保存在我的数据库中。这是代码:

$(document).ready(function() {

    var calendar = $('#calendar').fullCalendar({
        editable: true,
        events: "http://localhost/plann/events.php",
        defaultView: 'agendaWeek',
        selectable: true,
        editable: true,
        selectHelper: true,
        select: function(start, end, allDay) {
            var title = prompt('Event Title:');

            if (title) {
                start = moment(start, 'DD.MM.YYYY').format('YYYY-MM-DD')
                end = moment(end, 'DD.MM.YYYY').format('YYYY-MM-DD')

                $.ajax({
                    url: 'http://localhost/plann/add_events.php',
                    data: 'title='+ title+'&start='+ start +'&end='+ end ,
                    type: "POST",
                    success: function(json) {
                        alert('OK');
                    }
                });

                calendar.fullCalendar('renderEvent',
                {
                    title: title,
                    start: start,
                    end: end,
                    allDay: allDay
                },
                    true // make the event "stick"
                );
            }
            calendar.fullCalendar('unselect');
        },

        eventDrop: function(event, delta) {
            start = moment(event.start, 'DD.MM.YYYY').format('YYYY-MM-DD')
            end = moment(event.end, 'DD.MM.YYYY').format('YYYY-MM-DD')

            $.ajax({
                url: 'http://localhost/plann/update_events.php',
                data: 'title='+ event.title+'&start='+ start +'&end='+ end +'&id='+ event.id ,
                type: "POST",
                success: function(json) {
                    alert("OK");
                }
            });
        },

        eventResize: function(event) {
            start = moment(event.start, 'DD.MM.YYYY').format('YYYY-MM-DD')
            end = moment(event.end, 'DD.MM.YYYY').format('YYYY-MM-DD')

            $.ajax({
                url: 'http://localhost/plann/update_events.php',
                data: 'title='+ event.title+'&start='+ start +'&end='+ end +'&id='+ event.id ,
                type: "POST",
                success: function(json) {
                    alert("OK");
                }
            });  
        }
    });

});

0 个答案:

没有答案
相关问题