Inside my main.js file:
define(['require'], function(require) {
require([
'../libs/requirejs/plugins/domReady',
'../core',
'../ndn.2',
'../Ndn/Widget'
],
function(domReady) {
// require('../Ndn/Widget'); // I tried this too, but it doesn't solve my problem
console.log('Should have required everything...');
domReady(function() {
console.log('About to call init()');
init();
});
}
)});
function init() {
// Begin fetching this widget's delivery settings
Ndn_Widget.fetchDeliverySettings();
// ... Other code here ...
}
In my Ndn/Widget.js file, I have the following:
var Ndn_Widget;
define(['require'], function(require) {
require(['../ndn.2', './ServerInterface'], function() {
/**
* An associative array for the different delivery settings
* @var Object
*/
var deliverySettings = {};
Ndn_Widget = {
fetchDeliverySettings: function() {
// ... code here
console.log('Finished defining Ndn_Widget.');
}
};
});
});
I am expecting that the anonymous function I pass to the define() function inside of main.js would only be executed after the "../Ndn/Widget.js" file has been loaded, but this is not always the case.
This is an example of my console.log statements:
Should have required everything...
About to call init()
Uncaught TypeError: Cannot call method 'fetchDeliverySettings' of undefined
Just finished defining Ndn_Widget.
Can someone tell me what I'm doing wrong? Thank you in advance!