code: function (type, data, bNoDetach) {
          var evt = createEvent(type, data);
          if (typeof documentEventHandlers[type] !== 'undefined') {
              if (bNoDetach) {
                  documentEventHandlers[type].fire(evt);
              } else {
                  setTimeout(function () {
                      // Fire deviceready on listeners that were registered before cordova.js was loaded.
                      if (type === 'deviceready') {
                          document.dispatchEvent(evt);
                      }
                      documentEventHandlers[type].fire(evt);
                  }, 0);
              }
          } else {
              document.dispatchEvent(evt);
          }
      }
docs: Method to fire event from native code
  bNoDetach is required for events which cause an exception which needs to be caught in native code