My primary application loads JavaScript files based on the page being visited:
var MainApp = (function() {
function loadPage(folder, template) {
$.getScript('scripts/' + template + '.js')
.done(function() {
console.log(template + " script loaded.");
});
}
function executeFunction() {
// do something ...
}
})();
The JavaScript code being loaded in $.getScript()
is structured like this:
var Utilities = (function() {
// try to call executeFunction()
})();
I am wondering how I can call MainApp.executeFunction()
from within Utilities()
.
When I attempt to use MainApp.executeFunction()
, it shows that MainApp is undefined. And when I try just executeFunction()
, the function appears to be undefined as well.