I am trying to add a character to the event header and what is happening is the result of the last event that is loaded is being placed on every event header.
i.e. if result is a red R then every event get a red R even if it should have a black R.
Any help would be appreciated.
I am running the following code in the scheduler.templates.event_header = function(start,end,event){
let redlinesExist = eventTopicRedlinesExist(event.topic_id);
if (redlinesExist){
console.log(event.id + "setting BLACK");
sNewHeader += ' - <font color="black"><strong>R</strong></font>';
}else{
console.log(event.id + "setting RED");
sNewHeader += ' - <font color="red"><strong>R</strong></font>';
}
The below function checks if the topicID is in a database table.
function eventTopicRedlinesExist(topicID){
return new Promise((resolve, reject) => {
$.ajax({
type: "GET",
url: "../endpoints/eventTopicRedlinesExist.php",
dataType: "json",
data: {"topicid": topicID},
async: false,
success: function (response) {
var exists = false;
$(".event-comment").remove();
$(".not-avail").removeClass("not-avail");
topicRedlinesExist = response;
if(topicRedlinesExist.length > 0 && topicRedlinesExist[0].TRUE){
exists = topicRedlinesExist[0].TRUE=='1';
}else{
exists = false;
}
resolve(exists);
},
error: function(xhr, textStatus, errorThrown) {
reject(false);
}
});
});
}