1 回答
TA贡献1951条经验 获得超3个赞
<script type="text/javascript">
document.addEventListener('DOMContentLoaded', function() {
var calendarEl = document.getElementById('calendar');
var calendar = new FullCalendar.Calendar(calendarEl, {
now: '<?php echo $CurrentDate; ?>',
editable: true,
aspectRatio: 1.8,
headerToolbar: {
left: 'today prev,next',
center: 'title',
right: 'resourceTimelineDay,timeGridWeek,dayGridMonth'
},
views: {
timeGridWeek: {
type: 'timeGrid',
duration: { weeks: <?php if($searchWeek=="") { echo 1; } else{echo $searchWeek;} ?> }
}
},
resources: <?php eventGroups(); ?>,
events: function(fetchInfo, successCallback, failureCallback) {
var fromDate = "<?php echo $fromDate; ?>";
var toDate = "<?php echo $toDate; ?>";
$.ajax({
url: "ajaxRefresh.php",
type: "POST",
dataType: "json",
success: function(response){
var events = [];
$.each(response, function (i, item) {
events.push({
id: response[i].id,
start: response[i].start,
end: response[i].end,
title: response[i].title,
});
});
successCallback(events);
}
});
},
dateClick: function(info) {
$('#addScheduleEntry').modal('show');
$.ajax({
url: "calendar_event_create.php",
type: "POST",
data: $("#frmEvent").serialize(),
dataType: 'json',
async : false,
success: function(response){
if(response.result == 'success'){
calendar.refetchEvents();
}
}
});
},
eventClick: function(info, jsEvent, view) {
var text = JSON.stringify(info, function (key, value) {
var eventId = info.event._def.publicId;
$("#eventDetail").modal("show");
$(document).on('click', '.removeEvent', function() {
var eventId = $("#event_id").val();
var yes = confirm("Are you sure ?");
if(yes == true){
$("#process_loader").fadeIn();
$.ajax({
url: "calendar_event_remove.php",
type: "POST",
data: {eventId:eventId},
dataType: 'json',
async : false,
success: function(response){
if(response.msg == "true"){
calendar.refetchEvents();
}
}
});
}
});
},
editable: true,
eventDrop: function(info, delta, revertFunc, ui) {
$.ajax({
url: "save_drop_event_detail.php",
type: "POST",
data: {EventId:EventId,oldUserId:oldUserId,newUserId:newUserId,newEventStartTime:newEventStartTime,newEventEndTime:newEventEndTime},
dataType: 'json',
async : false,
success: function(response){
if(response.msg == 'success'){
calendar.refetchEvents();
}
}
});
},
eventConstraint: {
slotMinTime: '10:00' ,
slotMaxTime: '11:00'
}
});
calendar.render();
});
</script>
我们使用了这个函数“ calendar.refetchEvents(); ”,并为您的事件使用了 AJAX 数据源,而不是静态数据源。
- 1 回答
- 0 关注
- 137 浏览
添加回答
举报