Search code examples
javascriptgoogle-drive-apigoogle-drive-realtime-api

Onfileloaded event not called when file is opened from Drive


I am trying to open a file in my Google Drive which was created by my Google Realtime application. Although the URL opens correctly, the onfileloaded event is not fired following the afterAuth event. Should I expect and handle a different event in my application when the file created by it is opened from Google Drive. Copying the URL in a different window fires the onfileload event.

OnfileLoaded:

function onFileLoaded(doc) {
  Util.log.console("Doc:");
  Util.log.console(doc);
  data = doc.getModel().getRoot().get('data');
}

I also tried handling the onLoad (of model) event. Didn't help either.


Solution

  • /**
     * Parses the hash parameters to this page and returns them as an object.
     * @function
     */
    rtclient.getParams = function() {
      var params = {};
      // The following statement was changed from window.location.hash
      // to window.location.search.  There was no hash in the URL.  So
      // .hash was returning an empty string.
      var hashFragment = window.location.search;
      if (hashFragment) {
        // split up the query string and store in an object
        var paramStrs = hashFragment.slice(1).split("&");
        for (var i = 0; i < paramStrs.length; i++) {
          var paramStr = paramStrs[i].split("=");
          params[paramStr[0]] = unescape(paramStr[1]);
        }
      }
      return params;
    }
    

    in the realtime-client-utils.js fixed it