通过dayClick创建新事件后保存对话框我使用此代码
addEvent(calEvent); // запиcываем в БД при создании eventa
$dialogContent.dialog("close");
$('#calendar').fullCalendar('removeEventSource', source1);
$('#calendar').fullCalendar('removeEventSource', source2);
$('#calendar').fullCalendar('removeEventSource', source3);
$('#calendar').fullCalendar('removeEvents'); // need it for not generating doubles of events
var source1 =
{
url: '/admin_schedule/get_schedule_db/',//"<?echo $data_path?>",
};
var source2 = {
url: '/admin_schedule/get_schedule_db_recurring_events/',//"<?echo $data_path?>",
backgroundColor: 'green',
//borderColor: 'yellow',
//textColor: 'black' // an option!
};
var source3 = {
url: '/admin_schedule/get_schedule_db_recurring_events_on_daysweek/',//"<?echo $data_path?>",
backgroundColor: 'red',
};
$('#calendar').fullCalendar('addEventSource', source1); // without this 3 lines fullcalendar doesn't refetch in Safari, but WITH them it renders doubles in all browsers
$('#calendar').fullCalendar('addEventSource', source2);
$('#calendar').fullCalendar('addEventSource', source3);
$calendar.fullCalendar('updateEvent', calEvent); // обновляет календарь после закрытия dialog'а
//$calendar.fullCalendar('renderEvents');
$calendar.fullCalendar('rerenderEvents');
$('#calendar').fullCalendar('refetchEvents');
它不会在Safari和Opera浏览器中重新呈现日历事件。但它适用于Chrome和Firefox。 错误在哪里?
答案 0 :(得分:2)
只需在refetchEvents
函数内调用addEvent()
。
所以在保存对话框中离开
addEvent(calEvent); // запиcываем в БД при создании eventa
$dialogContent.dialog("close");
并添加到addEvent: $(&#39;#calendar&#39;)。fullCalendar(&#39; refetchEvents&#39;);
function addEvent(calEvent) {
//var start = Date.parse(calEvent.start) / 1000; // 1323930600
//var end = Date.parse(calEvent.end) / 1000;
var start = $.fullCalendar.formatDate(calEvent.start, "yyyy-MM-dd HH:mm");
var end = $.fullCalendar.formatDate(calEvent.end, "yyyy-MM-dd HH:mm");
var recurring_start = $.fullCalendar.formatDate(calEvent.recurring_start, "yyyy-MM-dd");
var recurring_end = $.fullCalendar.formatDate(calEvent.recurring_end, "yyyy-MM-dd");
//set form data into a variable
var dataString = 'title='+calEvent.title+'&start='+start+'&end='+end+'&recurring_start='+recurring_start+'&recurring_end='+recurring_end+'&frequency_as_day='+calEvent.frequency_as_day+'&body='+calEvent.body+'&teacher_id='+calEvent.teacher_id;
dataString = dataString + calEvent.days;
$.ajax({
type:"POST",
url:"<?=base_url().'admin_schedule/add_schedule/'?>",
data: dataString,
success:function(html){
$('#calendar').fullCalendar('refetchEvents');
//on succes clear form
//$("form").clearForm();
//show result
//$(".helper").html(html).fadeIn('slow').animate({opacity: 1.0}, 2000);
//remove old fullcalendar data source
//$("#calendar").fullCalendar( 'removeEventSource', '<?echo $data_path?>' )
//add a new one
//$("#calendar").fullCalendar( 'addEventSource','<?echo $data_path?>');
}
});
return false;
}