| HD$ RegisterHandler Method |
JavaScript API: Embedded
Assembly: hotdocs.js Version: 1.0.0.0 (1.0.0.0)
function RegisterHandler(eventName, handler, callback);
Parameters
- eventName
- Type: System
String
A string representing the name of an interview event. You can specify any string, but only those listed below (see Remarks) are supported and will cause your event handler to be called. - handler
- Type: function
A JavaScript function that will be called any time the event for which it is registered occurs. It should accept a single parameter, EventArgs, the contents of which vary depending on the event as described below. - callback
- Type: function
A function to call after the handler is registered.
- "OnHDStart" - This event fires when an interview is fully loaded and initialized in the browser, but before the user has a chance to interact with the interview. For example, if you want to dictate that the user should begin the interview at any dialog besides the first one, you could register for this event and call the HDGotoInterviewBookmark function to set an alternate starting point for the user's interview.
The EventArgs object passed to your event handler does not have any properties.
- "OnHDNavigated" - This event fires when the user navigates to a new dialog, including the dialog first displayed when starting the interview. It is fired after the dialog script has run for the new dialog, and after the display has been updated. (In the case of the first dialog, it is fired after the OnHDStart event.)
If you make changes to answers in your handler, you should call HDScreenRefresh as usual to make sure the screen gets refreshed afterwards.
The EventArgs object passed to your event handler has the following properties:
Property Description DialogName The name of the dialog to which the user has navigated. - "PreHDNavigate" - This event fires at the time the user attempts to navigate away from a dialog. It fires after any pending answer changes have been saved, but before focus has actually moved away from the current dialog.
The EventArgs object passed to your event handler has the following properties:
Property Description DialogName This is the name of the dialog the user is attempting to leave. TargetName This is the name of the dialog to which the user is attempting to navigate. Cancel If you set this Boolean property to true, the user's attempt to navigate away from the dialog will be cancelled.
Caution: If you cancel the user’s navigation, it is strongly recommended that you supply a CancelMessage. If you do not, you should undertake some other means of communicating to the user why they are not being allowed to navigate away from the current dialog.CancelMessage If navigation was cancelled and this property is a non-empty string, a message box is displayed to the user to indicate why navigation was cancelled. - "OnHDFinish" - This event fires when the user clicks the Finish button, after HotDocs first ensures that all required variables have been answered. You can use this function to perform custom answer validation and potentially cancel the user's action if needed.
The EventArgs object when this event is called has the following properties:
Property Description Cancel If you set this Boolean property to true, the user's attempt to finish the interview will be cancelled, leaving them at the current dialog.
Caution: If you cancel the user’s navigation, it is strongly recommended that you supply a CancelMessage. If you do not, you should undertake some other means of communicating to the user why they are not being allowed to finish their interview.CancelMessage If navigation was cancelled and this property is a non-empty string, a message box is displayed to the user to indicate why navigation was cancelled. - "OnHDProgress" - This event fires every time a variable is answered (or cleared) or the interview content otherwise changes, such that information about the user's progress towards completion of the interview has changed. You might use this event if you have suppressed display of the built-in interview progress bar (using the HDShowProgressBar variable) and wish to track user progress through some alternate means.
The EventArgs object when this event is called has the following properties:
Property Description Answered The number of answered questions, not counting answers to optional questions Total The total number of questions in the interview (not counting optional questions) State A number indicating the state of the interview as a whole. - 0: Interview is complete. If the interview progress bar were visible and had the default styling applied, this would correspond to a green, fully complete progress bar.
- 1: Interview is incomplete. If the interview progress bar were visible and had the default styling applied, this would correspond to a blue progress bar in an empty or partially-complete state.
- 2: Interview is incomplete, and one or more of the unanswered questions are required before the user is allowed to progress further. If the interview progress bar were visible and had the default styling applied, this is one of two states that would display a red progress bar.
- 3: The interview contains a dialog with an error message, which prevents the user from progressing. If the interview progress bar were visible and had the default styling applied, this is one of two states that would display a red progress bar.
- 4: The interview is incomplete, there is one or more required unanswered question, and a dialog contains an error message. Because of this state, the user cannot progress further in the interview. If the interview progress bar were visible and had the default styling applied, this is one of two states that would display a red progress bar.
- "OnDocumentsAssembled" - This event fires after a document or series of documents has been assembled, and before the next interview, if any, is presented.
The EventArgs object when this event is called has the following properties:
Property Description Answers An XML document containing the answers as of the most recent assembly. History An array containing all of the events that have occurred in this session. Each event has the following properties: Property Description Type - "Interview": An interview is presented.
- "AssembledDocument: A document is assembled.
TemplateName The name of the template in the package, if not the default. TemplateTitle The title of the template. Format A comma-delimited list of types of documents produced. - "Answers": An XML answer file.
- "Native": The default type for the given template type. ** TODO Does this ever happen? **
- "PDF": A PDF document.
- "HTML": An HTML document.
- "PlainText": A text document.
- "HTMLwDataURIs": An HTML document with embedded images. Not available for Internet Explorer 8 and older. ** TODO Is this correct?
- "MHTML": A multipart HTML document. Not available for ????.
- "RTF": A Microsoft RTF document.
- "DOCX": A Microsoft DOCX document.
- "WPD": A WordPerfect WPD document.
- "HPD": A HotDocs fillable document. ** TODO Is this correct?
- "HFD": ???
UnansweredVariables An array of the names of unanswered variables. Url The URL from which the document, if any, can be downloaded, if available. NewlyAssembledDocuments An array of URLs from which the most recently assembled documents can be downloaded. This includes only the documents that were assembled since the most recent interview was conducted. PendingEvents An array of events that are known to be pending in the session. Each event has the following properties: Property Description Type - "Interview": An interview is presented.
- "AssembledDocument: A document is assembled.
TemplateName The name of the template in the package, if not the default. TemplateTitle The title of the template. Format A comma-delimited list of types of documents to be produced. - "Answers": An XML answer file.
- "Native": The default type for the given template type.
- "PDF": A PDF document.
- "HTML": An HTML document.
- "PlainText": A text document.
- "HTMLwDataURIs": An HTML document with embedded images. Not available for Internet Explorer 8 and older. ** TODO Is this correct?
- "MHTML": A multipart HTML document. Not available for ????.
- "RTF": A Microsoft RTF document.
- "DOCX": A Microsoft DOCX document.
- "WPD": A WordPerfect WPD document.
- "HPD": A HotDocs fillable document. ** TODO Is this correct?
- "HFD": ???
- "OnSessionCompleted" - This event fires after all interviews have been completed and all documents have been assembled.
The EventArgs object when this event is called has the following properties:
Property Description AssembledDocuments An array of file names of the documents assembled in this session. Error An error message, if any. - "OnSaveAnswers" - This event fires when the Save Answers button is clicked. This button is automatically added to the toolbar when a handler is registered for the OnSaveAnswers event.
The EventArgs object when this event is called has the following properties: