I tried my best to replicate the error outside my context but failed so, so I'll have to provide with it.
Code :
var view;
widget = {
activated: false,
close: function(){
this.view.popupManager.enabled = false;
}
}
view = new MapView({
}).then(function(){ //then is triggered when fully loaded;
console.log(this.popupManager) //Object!
widget.activated = true;
widget.view = this;
}
console.log(view.popupManager) //Undefined, not loaded yet
$('#my_button').click(function(){
if(widget.activated){
widget.close() //this.view.popupManager is undefined
}
})
This is using Esri's Javascript 4.3 API, but it doesn't seem to be the API, but some misuderstanding of my part on how scope works in Javascript.
As you can see, even though I only call widget.close
if view
is fully loaded, it still referencing the old, not fully loaded object
What am I missing?