在全日历外部拖动事件中,我想通过在复制事件时添加带有描述的数据库中插入的事件的ID来更改描述。
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.description = 'custom_event';
copiedEventObject.allDay = allDay;
copiedEventObject.className = $(this).attr("data-class");
var new_date = copiedEventObject.start.format();
var new_event = copiedEventObject.title;
$.post('calendar_action.php',{'action':'create_event','date':new_date,'event':new_event},function(data){
$(copiedEventObject).attr("description",data);
});
// 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);
$(this).remove();
},
ajax中的$ .post方法未传递全局变量,因此我使用了$ .ajax方法及其正常工作
$.ajax({
type: 'POST',
async: false,
url: "calendar_action.php",
data: {'action':'create_event','date':new_date,'event':new_event},
success: function(data) {
desc = data;
}
});
copiedEventObject.description = desc+'_custom_event';
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句