$.getScript(app.modulePath+'/'+ moduleName+'.js') //include file
.done(function()
{
app.loadedModules.push(moduleName); //track loaded modules
app.currentModule = moduleName; //assign module name to object property
});
I am loading javascript modules as I need them, but am having trouble referencing them. To load the module by name, I use a string and assign the string as the currentModule. But it's a string. How to I assign the loaded object which has the same name as the string.
Example:
Images.js
var Images = (function()
{
return {
allImages: function(){},
oneImage: function(){}
};
});
app.js
var moduleName = 'Images';
$.getScript(moduleName).done(function()
{
myApp.currentModule = moduleName;
//how to reference currentModule as object
});
evalwith a link from w3schools. That's some truly high level advice you've given.