I am working on a project with Advanced Custom Fields and Full Calendar. When clicking on a day on the calendar a window opens (using izimodal plugin for this) and you can create an event using requests that are inserted via ACF and are fetched from the fields. See image
When you pick a value from the select, it triggers a function that shows the “Request Details” above.
This is the function that is used to achieve that.
function getRequestDetails(){
var url = eventCreate['url'];
var requestID = jQuery("#acf-field_595cb1439530e").val();
var eventDate = jQuery("input[name=request-date]").val();
var startTime = jQuery("input[name=teaching-start-time]").val();
var endTime = jQuery("input[name=teaching-end-time]").val();
var postID = jQuery("#contanier-teacher-selection").attr('data-post-id');
var data = {
'action': 'get_request_details',
"requestID": requestID,
"eventDate": eventDate,
"startTime": startTime,
"endTime": endTime,
"postID": postID
};
//send ajax
jQuery.ajax({
url: url,
type: 'POST',
data: data,
success: function (data) {
jQuery("#request-details-metabox").html(data);
}
});
Now on another page given the acf-field for the request, you can create an event by choosing a date from the calendar. See Image. Now because izimodal window can’t be made draggable, the details of the request remain invisible in the background. When you choose a date from the date field, it triggers the teachers select field. I’d like to add to that function or call the previous one, so when that happens it shows the request details above like in the first picture. This is the function
function updateTeacherOptions() {
var url = eventCreate['url'];
var requestID = jQuery("#input-teaching-requests").val();
var eventDate = jQuery("input[name=request-date]").val();
var startTime = jQuery("input[name=teaching-start-time]").val();
var endTime = jQuery("input[name=teaching-end-time]").val();
var postID = 1;
var data = {
'action': 'create_event_update_teacher_select',
"requestID": requestID,
"eventDate": eventDate,
"startTime": startTime,
"endTime": endTime,
"postID": postID
};
//send ajax
jQuery.ajax({
url: url,
type: 'POST',
data: data,
success: function (data) {
jQuery("#contanier-teacher-selection").html(data);
}
});
This is its call, inside the same file.
jQuery(document).ready(function ($) {
$(document).on('change', '.create-request-event', function () {
updateTeacherOptions();
});
Now I want on the same event, to reveal the request details. How can I do this?