I am setting up a new manager based on the DataManager pattern.
The following works for DataManager:
DataManager.loadDatabase = function() {
...
this.loadDataFile(name, prefix + src);
...
};
DataManager.loadDataFile = function(name, src) {
...
}
but my manager gives me an Undefined is not a function error:
XRefManager.loadReferences = function() {
$dataActors.forEach(function(actor) { this.buildActorXRefs(actor); });
...
};
XRefManager.buildActorXRefs = function(actor) {
if (!actor) return;
};
The buildActorXRefs is what it's objecting to on the forEach line.
$dataActors exists and is populated at this point.
The first actor is null, but I moved the check for null actor into the forEach block and it made no difference.
My XRefManager is at the highest level, same as DataManager (not enclosed in my plugin function() {} body).
I'm hoping this will be obvious to someone else - it's sure not to me.
Edit: never mind. Figured out I needed a .bind(this) on the function. All working now. Until the next issue.
The following works for DataManager:
DataManager.loadDatabase = function() {
...
this.loadDataFile(name, prefix + src);
...
};
DataManager.loadDataFile = function(name, src) {
...
}
but my manager gives me an Undefined is not a function error:
XRefManager.loadReferences = function() {
$dataActors.forEach(function(actor) { this.buildActorXRefs(actor); });
...
};
XRefManager.buildActorXRefs = function(actor) {
if (!actor) return;
};
The buildActorXRefs is what it's objecting to on the forEach line.
$dataActors exists and is populated at this point.
The first actor is null, but I moved the check for null actor into the forEach block and it made no difference.
My XRefManager is at the highest level, same as DataManager (not enclosed in my plugin function() {} body).
I'm hoping this will be obvious to someone else - it's sure not to me.
Edit: never mind. Figured out I needed a .bind(this) on the function. All working now. Until the next issue.
Last edited by a moderator:
