I am creating a tool for employees to create a widget panel. This panel is fully customizable in terms of displaying widgets, their placement and size.
Each widget is a jquery self-starting function that loads everything it needs to have it created.
My concern is that some widgets may need to extract data from a database to load, such as stored links, popular phone numbers, etc. This will mean that if the user had 10 widgets on the control panel, making 10 AJAX calls (assuming that each of them is needed to access the database).
First, I doubt it is preferable, but not quite sure how to handle it otherwise?
My second problem / question is around waiting for things to load. In the function getMultipleScripts, I have a callback for done. This will tell me when all the files have been extracted, so I can run my plugin to enable grid functionality. However, this does not mean that each of the plugins has completed its AJAX call to retrieve its data. Is there a way I can approach this so that not only the files are loaded, but each of them has completed its initial AJAX call to retrieve its data?
$.getMultiScripts(moduleIncludes, 'includes/js/modules/').done(function(){
});
$.getMultiScripts = function(arr, path) {
var _arr = $.map(arr, function(scr) {
return $.getScript((path || "") + scr);
});
_arr.push($.Deferred(function(deferred) {
$(deferred.resolve);
}));
return $.when.apply($, _arr);
}
Any feedback on suggestions is preferable. Although the above questions concern my primary concern, feedback is also accepted around the alternative setup.
, - , . - , , - .
