_docs-v5/resource-data/resources-function.md
A custom function for programmatically generating raw Resources objects.<!--more--> This allows for any sort of asynchronous means of obtaining the resource list.
<div class='spec' markdown='1'> function( *fetchInfo*, *successCallback*, *failureCallback* ) { } </div>The function is given a successCallback argument that should be called with an array of raw Resource objects:
var calendar = new Calendar(calendarEl, {
resources: function(fetchInfo, successCallback, failureCallback) {
somethingAsynchonous(function(resources) {
successCallback(resources);
});
}
});
If there is some sort of failure, for example, if an AJAX request should fail, then call the failureCallback instead. It accepts an argument with information about the failure.
Instead of calling successCallback and failureCallback, you may return a Promise-like object instead.
If refetchResourcesOnNavigate is set to true, the resources function's fetchInfo argument will be populated with some useful arguments. It will receive the start and end dates for the newly visible window of time as well as the calendar's timezone:
var calendar = new Calendar(calendarEl, {
refetchResourcesOnNavigate: true,
resources: function(fetchInfo, successCallback, failureCallback) {
somethingAsynchonous({
start: fetchInfo.start,
end: fetchInfo.end,
timeZone: fetchInfo.timeZone
}, function(resources) {
successCallback(resources);
});
}
});
Complete list of properties in fetchInfo:
Note: This value is exclusive. For example, an event with the end of 2018-09-03 will appear to span through 2018-09-02, but end before the start of 2018-09-03. See how events are are parsed from a plain object for further details.