title: JavaScript code not working within a callback
body: <p>In the following JavaScript code, if warnBeforeNew is false, the file open code works. However, it doesn't if warnBeforeNew is true, instead giving an error "Uncaught TypeError: Cannot read property 'root' of undefined".</p>
  
  <p>I don't know if this is to do with scoping, but how do I get the file loading code to work within the callback? Thanks.</p>
  
  <pre><code>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));
    }
  };
  </code></pre>