我在ajax事件后调用但没有在日历上获取任何数据更新: 例如:如果我的日期是10到12,那么在调用refetchevent之后,它应该显示从10到12的彩色事件,但它仍然保持在10而不会移动。
Js代码:
$('#calendar').fullCalendar({ //re-initialize the calendar
header: h,
defaultView: 'month', // change default view with available options from http://arshaw.com/fullcalendar/docs/views/Available_Views/
slotMinutes: 15,
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');
var drop_d = date.getDate();
var drop_m = date.getMonth();
var drop_m = drop_m + 1;
var drop_y = date.getFullYear();
var init_zero = "";
if(drop_d >= 1 && drop_d <= 9) {
var init_zero = "0";
} else {
var init_zero = "";
}
if(drop_m >= 1 && drop_m <= 9) {
var month_zero = "0";
} else {
var month_zero = "";
}
var drop_date = init_zero + drop_d + "/" + month_zero + drop_m + "/" + drop_y;
//alert(originalEventObject.title);
var caller = "1";
//alert(drop_date);
//here add call to the lightbox.....to fill the information....
$.ajax({
url: "vehicle_driver_bookwindow.php",
type: "POST",
data: {driver_name: originalEventObject.title, dropped_on_date: drop_date, caller_from: caller },
success: function(data) {
document.getElementById("bookwindow").innerHTML = data;
ComponentsPickers.init();
$("#a_bookwindow").click();
}
});
// 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.className = $(this).attr("data-class");
// 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();
}
},
/*eventSources: [
// your event source
{
url: "<?php include 'vehicle_json.php'; ?>", // use the `url` property
}
// any other sources...
],*/
//events: 'vehicle_json.php',
events: <?php include 'vehicle_json.php'; ?>,
eventDrop: function(event, delta, revertFunc) {
并在我尝试再次调用事件以再次显示事件并刷新。
$.ajax({
url: "save_booking_details.php",
type: "POST",
data: {booking_id: bookingid},
success: function(data){
//alert(data);
//location.reload();
//$('#calendar').fullCalendar('removeEventSource', curSource[0]);
//$('#calendar').fullCalendar('removeEventSource', curSource[0]);
$('#calendar').fullCalendar('refetchEvents');
&安培;它不起作用,有人可以告诉我我错过了什么或我错在哪里......
MY JSON PHP文件:
<?php $driver_booking = q("select * from vehicle_driver_booking where vehicle_id = ".$_REQUEST['ch']); $array = array(); foreach($driver_booking as $bookings) { $driver = getR("vehicle_driver", $bookings['driver_id']); //return date_time from only.... $date_from = date("Y-m-d",$bookings['datetime_from']); $time_from = date("H:i:s",$bookings['datetime_from']); //return date_time to only..... $date_to = date("Y-m-d",$bookings['datetime_to']); $time_to = date("H:i:s",$bookings['datetime_to']); if($bookings['days_option'] == 1) { $start = $date_from."T".$time_from; $array[] = array('id' => $bookings['id'], 'title' => $driver['name'], 'start' => $start, 'allDay' => false); } else { $start = $date_from."T".$time_from; $end = $date_to."T".$time_to; $array[] = array('id' => $bookings['id'], 'title' => $driver['name'], 'start' => $start, 'end' => $end, 'allDay' => false); } } echo json_encode($array); ?>
答案 0 :(得分:0)
问题是您在脚本中包含vehicle_json.php
文件。而不是包含文件而是传递url
。
$('#calendar').fullCalendar({
events: '/vehicle_json.php',//place your relevant url here
});
refetchEvents
重新获取所有来源的事件,并在屏幕上重新呈现它们,您只需传递文件中的json
数据vehicle_json.php