You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
therefore i've written a little generic eventManager:
var eventManager = {
fetchData: function (sources, callback) {
var sourcesLength = sources.length;
var pendingSourcesCount = sourcesLength;
var currentData = new Array();
for (var i = 0; i < sourcesLength; i++) {
var source = sources[i];
this._fetchDataFromSource(source, function (data) {
currentData = currentData.concat(data);
pendingSourcesCount--;
if (!pendingSourcesCount) {
callback(currentData);
}
});
}
},
_fetchDataFromSource: function (source, callback) {
if (typeof source == 'string') {
$.ajax({
'url': source,
'dataType': 'json',
'success': function (events) {
callback(events);
}
});
}
else if ($.isFunction(source)) {
source(function (events) {
callback(events);
});
}
else {
callback(source);
}
}
};
which can be used eg:
var $calendar = $('#selector').weekCalendar({
'data': function (start, end, callback) {
eventManager.fetchData([
function (internalCallback) {
var url = 'help1.wcf';
var data = {
'start': new Date(),
'end': new Date()
};
$.getJSON(url, data, function (data) {
internalCallback(data);
});
},
function (internalCallback) {
var url = 'help2.wcf';
var data = {
'start': new Date(),
'end': new Date()
};
$.getJSON(url, data, function (data) {
internalCallback(data);
});
}
], callback);
}
});
maybe sth like this shoule be integrated...
The text was updated successfully, but these errors were encountered:
atm you cannot declare multiple eventSources.
therefore i've written a little generic eventManager:
which can be used eg:
maybe sth like this shoule be integrated...
The text was updated successfully, but these errors were encountered: