最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Full Calendar saving events - Stack Overflow

programmeradmin0浏览0评论

I'm having some issues with saving the end time with fullcalendar and having it be able to be dragged to enpass more than one day on the calendar. I have it set to save data via jQuery.post to my database, but I can't seem to figure out how to get the end value to populate and the ability to drag it across more than one day. Here is my code I have in place:

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

             editable: true,
             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,
                     }, true);
                 }

                 calendar.fullCalendar('unselect');
             },

             eventDrop: function (event, dayDelta, minuteDelta) {
                 alert(event.title + ' was saved!');

                 jQuery.post(
                    '/event/save', 
                    {
                        title: event.title,
                        start: event.start,
                        end:   event.end
                    }
                 );
             }
        });

Any help would be appreciated! Thanks

(I can also provide a url if that helps anyone determine the issue)

I'm having some issues with saving the end time with fullcalendar and having it be able to be dragged to enpass more than one day on the calendar. I have it set to save data via jQuery.post to my database, but I can't seem to figure out how to get the end value to populate and the ability to drag it across more than one day. Here is my code I have in place:

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

             editable: true,
             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,
                     }, true);
                 }

                 calendar.fullCalendar('unselect');
             },

             eventDrop: function (event, dayDelta, minuteDelta) {
                 alert(event.title + ' was saved!');

                 jQuery.post(
                    '/event/save', 
                    {
                        title: event.title,
                        start: event.start,
                        end:   event.end
                    }
                 );
             }
        });

Any help would be appreciated! Thanks

(I can also provide a url if that helps anyone determine the issue)

Share Improve this question edited Jan 20, 2016 at 14:27 Jason Roman 8,27610 gold badges36 silver badges43 bronze badges asked Mar 7, 2014 at 17:00 user2101411user2101411 1,2023 gold badges15 silver badges36 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 5

Your code looks good. Its almost there. You need to implement the eventResize to save the effect of dragging the event across days. ideally, create a function to post your data and call it from each event.

function saveMyData(event) {
    jQuery.post(
        '/event/save', 
        {
            title: event.title,
            start: event.start,
            end:   event.end
        }
    );
}

...
select: function (start, end, allDay) {
            var title = prompt('Event Title:');
            if (title) {
                calendar.fullCalendar('renderEvent', {
                    title: title,
                    start: start,
                    end: end,
                    }, true);
                }

                calendar.fullCalendar('unselect');
                saveMyData({'title': title, 'start': start, 'end': end});
            },

eventDrop: function (event, dayDelta, minuteDelta) {
               saveMyData(event);
           },

eventResize: function (event, dayDelta, minuteDelta) {
                 saveMyData(event);
             }
...
发布评论

评论列表(0)

  1. 暂无评论