Reputation: 540
I am using fullcalendar eventSources to pull json event data from server. I have a variable sheet_id
that changes and the selected_sheet_id()
function will return the corresponding sheet selected. The problem is that when I call $("#calendar").fullCalendar('refetchEvents')
to return events, sheet_id
(thus all the events) are always the same. That is fullcalendar does not get refreshed with the current sheet_id
before fetching events. How do I trigger the eventSources to "recompile" so that it pulls the correct sheet_id
from the function before executing ajax call.
eventSources: [{
url: '/event/get_events',
type: 'GET',
data: {
sheet_id: selected_sheet_id()
},
error: function() {
alert('there was an error while fetching events!');
}
}]
Upvotes: 0
Views: 1452
Reputation: 5810
First Try this with async:false
for sync call :
eventSources: [
{
url: '/event/get_events',
type: 'GET',
async:false,
data:{
sheet_id: selected_sheet_id()
},
error: function() {
alert('there was an error while fetching events!');
},
},
]
Otherwise made one method which fetch event data in using Ajax call
For ex :
var ajaxreturnstring="";
$.ajax({
type: "POST",
url: "/EMR-PHR/getPatientScheduleajax.html",
dataType:"html",
data: "",
async:false,
success: function(data){
ajaxreturnstring=$.trim(data);
var obj = eval("("+txt+")");
return obj;
},
error: function(e){
alert('Error: ' + e);
}
});
}
Upvotes: 1