Hello.
I need to load some data in to custom tooltip using Ajax. My code is working fine but only if I use synchronous mode (which I don’t want to do). I wrote the code to use async data loading and I think it’s ok but nothing is shown when hovering over events. Can you please tell me why that is ? Or how to upgrade my code so this will work ?
Working code (sync)
//Custom tooltip
scheduler.templates.tooltip_text = function (start, end, ev) {
var dataToPost = "{ nrOfOrder:'" + ev.text + "'}";
var extraData;
$.ajax({
type: "POST",
url: '/Scheduler/GetTooltipParameters',
contentType: 'application/json; charset=utf-8',
dataType: 'json',
cache: false,
data: dataToPost,
async: false,
success: function (data) {
extraData = data;
}
})
var tooltip_text =
"<b>Zdarzenie:</b> " + ev.text + "<br/>" +
"<b>Data start:</b> " + scheduler.templates.tooltip_date_format(start) + "<br/>" +
"<b>Data koniec:</b> " + scheduler.templates.tooltip_date_format(end) + "<br/>" +
extraData;
return tooltip_text;
};
Not working (async)
//Custom tooltip
scheduler.templates.tooltip_text = function (start, end, ev) {
var dataToPost = "{ nrOfOrder:'" + ev.text + "'}";
$.ajax({
type: "POST",
url: '/Scheduler/GetTooltipParameters',
contentType: 'application/json; charset=utf-8',
dataType: 'json',
cache: false,
data: dataToPost
}).done(function (data) {
var tooltip_text = "<b>Zdarzenie:</b> " + ev.text + "<br/>" +
"<b>Data start:</b> " + scheduler.templates.tooltip_date_format(start) + "<br/>" +
"<b>Data koniec:</b> " + scheduler.templates.tooltip_date_format(end) + "<br/>"
+ data;
return tooltip_text;
}).fail(function (jqXHR, textStatus) {
//Handle error here, I put an alert
alert("Request failed: " + textStatus);
}); //End of fail handler
};