1

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 では機能します。間違いはどこにありますか?

4

1 に答える 1

2

関数refetchEvents内で呼び出すだけです。addEvent()

そのため、保存ダイアログのままにします

addEvent(calEvent); // запиcываем в БД при создании eventa 
    $dialogContent.dialog("close");

そして addEvent に追加します: $('#calendar').fullCalendar('refetchEvents');

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;
}    
于 2012-11-10T18:21:35.227 に答える