Twitter bootstrap Bootstrap Fullcalendar存储对象-我在chrome上添加/修改一个对象,但在刷新日历后,更改消失了

Twitter bootstrap Bootstrap Fullcalendar存储对象-我在chrome上添加/修改一个对象,但在刷新日历后,更改消失了,twitter-bootstrap,fullcalendar,Twitter Bootstrap,Fullcalendar,如何存储对象,直到我决定修改或删除。我通过web浏览器进行更改,比如在对象中拖动或在日历中单击,但在刷新页面后,会返回默认设置。胸带。谢谢你的帮助 $(document).ready(function () { /* initialize the external events -----------------------------------------------c ------------------*/ $('#external

如何存储对象,直到我决定修改或删除。我通过web浏览器进行更改,比如在对象中拖动或在日历中单击,但在刷新页面后,会返回默认设置。胸带。谢谢你的帮助

 $(document).ready(function () {


        /* initialize the external events
        -----------------------------------------------c ------------------*/

        $('#external-events div.external-event2').each(function () {

            // create an Event Object (http://arshaw.com/fullcalendar/docs/event_data/Event_Object/)
            // it doesn't need to have a start or end
            var eventObject = {
                title: $.trim($(this).text()) // use the element's text as the event title
            };

            // store the Event Object in the DOM element so we can get to it later
            $(this).data('eventObject', eventObject);

            // make the event draggable using jQuery UI
            $(this).draggable({
                zIndex: 999,
                revert: true,      // will cause the event to go back to its
                revertDuration: 0  //  original position after the drag
            });






        });







        /* initialize the external events
        -----------------------------------------------c ------------------*/

        $('#external-events div.external-event').each(function () {

            // create an Event Object (http://arshaw.com/fullcalendar/docs/event_data/Event_Object/)
            // it doesn't need to have a start or end
            var eventObject = {
                title: $.trim($(this).text()) // use the element's text as the event title
            };

            // store the Event Object in the DOM element so we can get to it later
            $(this).data('eventObject', eventObject);

            // make the event draggable using jQuery UI
            $(this).draggable({
                zIndex: 999,
                revert: true,      // will cause the event to go back to its
                revertDuration: 0  //  original position after the drag
            });






        });


        /* initialize the calendar
        -----------------------------------------------------------------*/

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

            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: allDay
                        },
                        true // make the event "stick"
                    );
                }
                // calendar.fullCalendar('unselect');
            },




            eventClick: function (calEvent, jsEvent, view) {


                var title = prompt('Rename Event Title:');

                calEvent.title = title;
                // copiedEventObject.title = title;
                alert('Altered Event : ' + calEvent.title);


                // change the border color just for fun
                $(this).css('border-color', 'red');

            },







            editable: true,
            droppable: true, // this allows things to be dropped onto the calendar !!!
            drop: function (date, allDay) { // this function is called when something is dropped

                // retrieve the dropped element's stored Event Object
                var originalEventObject = $(this).data('eventObject');


                // we need to copy it, so that multiple events don't have a reference to the same object
                var copiedEventObject = $.extend({}, originalEventObject);

                // assign it the date that was reported
                copiedEventObject.start = date;
                copiedEventObject.allDay = allDay;
                //    copiedEventObject.title = 'abc';     //<<<Change the title



                // render the event on the calendar
                // the last `true` argument determines if the event "sticks" (http://arshaw.com/fullcalendar/docs/event_rendering/renderEvent/)
                $('#calendar').fullCalendar('renderEvent', copiedEventObject, true);

                // is the "remove after drop" checkbox checked?
                if ($('#drop-remove').is(':checked')) {
                    // if so, remove the element from the "Draggable Events" list
                    $(this).remove();
                }

            }
        });


    });
$(文档).ready(函数(){
/*初始化外部事件
-----------------------------------------------c------------------*/
$('#外部事件div.external-event2')。每个(函数(){
//创建一个事件对象(http://arshaw.com/fullcalendar/docs/event_data/Event_Object/)
//它不需要有开始或结束
var eventObject={
title:$.trim($(this).text())//使用元素的文本作为事件标题
};
//将事件对象存储在DOM元素中,以便我们以后可以访问它
$(this).data('eventObject',eventObject);
//使用jQuery UI使事件可拖动
$(此)。可拖动({
zIndex:999,
revert:true,//将导致事件返回其初始状态
revertDuration:0//拖动后的原始位置
});
});
/*初始化外部事件
-----------------------------------------------c------------------*/
$('#外部事件div.external-event')。每个(函数(){
//创建一个事件对象(http://arshaw.com/fullcalendar/docs/event_data/Event_Object/)
//它不需要有开始或结束
var eventObject={
title:$.trim($(this).text())//使用元素的文本作为事件标题
};
//将事件对象存储在DOM元素中,以便我们以后可以访问它
$(this).data('eventObject',eventObject);
//使用jQuery UI使事件可拖动
$(此)。可拖动({
zIndex:999,
revert:true,//将导致事件返回其初始状态
revertDuration:0//拖动后的原始位置
});
});
/*初始化日历
-----------------------------------------------------------------*/
var calendar=$(“#calendar”).fullCalendar({
标题:{
左:“上一个,下一个今天”,
中心:'标题',
右图:“月,agendaWeek,agendaDay”
},
是的,
selectHelper:对,
选择:功能(开始、结束、全天){
var title=prompt('事件标题:');
如果(标题){
日历。完整日历('renderEvent',
{
标题:标题,,
开始:开始,
完:完,,
全天
},
true//使事件“持续”
);
}
//日历。完整日历(“取消选择”);
},
eventClick:函数(calEvent、jsEvent、view){
var title=prompt('Rename Event title:');
calEvent.title=标题;
//copiedEventObject.title=标题;
警报(“更改的事件:”+calEvent.title);
//更改边框颜色只是为了好玩
$(this.css('border-color','red');
},
是的,
可拖放:true,//这允许将内容拖放到日历上!!!
drop:function(date,allDay){//在删除某些内容时调用此函数
//检索已删除元素的存储事件对象
var originalEventObject=$(this.data('eventObject');
//我们需要复制它,这样多个事件就不会引用同一个对象
var copiedEventObject=$.extend({},originalEventObject);
//将其指定为报告的日期
copiedEventObject.start=日期;
copiedEventObject.allDay=全天;

//copiedEventObject.title='abc';//您应该使用
AJAX
请求将事件存储在数据库中。然后在
drop:function();
上从相同的数据库中获取事件。请尝试以下代码:

drop: function(date, allDay, jsEvent, ui) { // this function is called when something is dropped
    // retrieve the dropped element's stored Event Object
    var originalEventObject = $(this).data('eventObject');

    // we need to copy it, so that multiple events don't have a reference to the same object
    var copiedEventObject = $.extend({}, originalEventObject);

    //cvalculate endTime using duration of event
    var endTime = date.getTime() + (copiedEventObject.duration*60000);

   //function to store event data to db.
   saveEventData(date, allDay, copiedEventObject, endTime, copiedEventObject.duration);
}
保存事件数据功能

 //function to save events when droped external events
function saveEventData(start, allday, copiedEventObject, endTime, duration) {
    jQuery.ajax({
            url: ''//url to your code,
            type: 'post',
            cache: false,
            data: {'start':start, 'allday': allday, 'end': endTime, 'additional_info':copiedEventObject},
            success: function (response) {
                    $('#calendar').fullCalendar('renderEvent', copiedEventObject, true);
            }
        });
}
现在尝试将
事件:'//url添加到json提要中
到日历中,或者您可以使用另一种方法
事件
作为数组