Я использую FullCalendar в codeigniter для отображения данных, пользователь вставляет данные, нажав кнопку, после чего FullCalendar отобразит их. но моя проблема в том, что пользователю приходится обновлять страницу, чтобы данные могли отображаться в полном календаре.
Ниже мой контроллер.
Код: Выделить всё
public function showRecords() {
$employeeid = getSession('empid');
$data = $this->attendance->getAttendanceRecords($employeeid);
echo json_encode($data);
}
Код: Выделить всё
$(document).ready(async function() {
let recordJson;
await $.post('', function(data) {
recordJson = JSON.parse(data);
});
setTimeout(function() {
let calendarEl = document.getElementById('fullCalendar');
let fullCalendar = new FullCalendar.Calendar(calendarEl, {
themeSystem: 'bootstrap5',
headerToolbar: {
left: 'attendanceLog',
center: 'title',
right: 'today,prev,next'
},
customButtons: {
attendanceLog: {
text: 'Attendance Log',
click: function(info) {
let recordObj = info.event
const recordURL = '' + recordObj.id
if(recordObj) {
modalForm(
'Attendance Records',
'modal-sm',
recordURL,
)
}
}
}
},
eventDisplay: 'background',
events: recordJson,
eventClick: function(info) {
let eventObj = info.event
const formURL = '' + eventObj.id
if(eventObj) {
modalForm(
'Attendance',
'modal-md',
formURL,
)
}
}
});
fullCalendar.render();
}, 200);
});
i'm already using fullCalendar.refetch() but it does'nt work so i make my own which is does'nt work too
Код: Выделить всё
function refetch() {
const fullCalendar = document.getElementById('fullCalendar')
$.ajax({
type: 'GET',
url: "",
dataType: "json",
success: function(response) {
fullCalendar.render()
},
error: function(xhr, ajaxOptions, thrownError) {
showError(thrownError + ", please contact administrator for further assistance");
}
});
}
code below is how data will be saved(might help you guys understand)
Код: Выделить всё
$(document).ready(function() {
$('#form-attendance').on('submit', function(e) {
e.preventDefault();
let csrf = decrypter($("#csrf_token").val())
$("#csrf_token_form").val(csrf);
let link = ""
let form_type = ""
if(form_type == 'clocked') {
link = ""
}
let data = $(this).serialize();
$.ajax({
type: 'POST',
url: link,
data: data,
dataType: "json",
success: function(response) {
$("#csrf_token").val(encrypter(response.csrfToken))
$("#csrf_token_form").val("")
let pesan = response.pesan;
let notif = 'success';
if (response.sukses != 1) {
notif = 'error'
if (response .pesan != не определено) {
pesan = response.pesan
showNotif(notif, pesan)
if (response.sukses == 1) {
refetch ();
close_modal('modaldetail')
},
ошибка: function(xhr, ajaxOptions, throwError) {
showError(thrownError + ", пожалуйста обратитесь к администратору для получения дополнительной помощи");
});
return false;
});
});
пожалуйста, помогите мне, ребята
Источник: https://stackoverflow.com/questions/781 ... nsert-data
Мобильная версия