When the warnBeforeNew variable is set to false in the JavaScript code below, the file open function works as expected. However, when warnBeforeNew is true, an error occurs stating "Uncaught TypeError: Cannot read property 'root' of undefined".
I'm not sure if this issue is related to scoping, but I need help getting the file loading code to execute properly within the callback function. Thank you.
Editor.prototype.open = function(path) {
if (Editor.warnBeforeNew == true){
this.showDialog({
dialogLabel: 'You have unsaved changes. Are you sure you want to discard them and open a different file?',
submitLabel: 'Discard',
cancelLabel: 'Cancel',
submitCallback: function() {
Editor.warnBeforeNew = false;
this.filesystem.root.getFile(path, {}, this.load.bind(this), error.bind(null, "getFile " + path));
}
});
} else {
this.filesystem.root.getFile(path, {}, this.load.bind(this), error.bind(null, "getFile " + path));
}
};