From c79f8ae2d50fc6da75161961cfd66d0ed59434b5 Mon Sep 17 00:00:00 2001 From: rockwellll Date: Mon, 14 Oct 2024 11:09:40 +0300 Subject: [PATCH] remove autoMountForms from configuration --- README.md | 10 +++++----- docs/forms.md | 17 +++++++++++++++++ 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 0b4c1a5..f2f56d7 100644 --- a/README.md +++ b/README.md @@ -123,8 +123,8 @@ Hellotext.initialize('HELLOTEXT_BUSINESS_ID', configurationOptions) #### Configuration Options -| Property | Description | Type | Default | -|---------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------|---------| -| session | A valid Hellotext session which was stored previously. When not set, Hellotext attempts to retrieve the stored value from `document.cookie` when available, otherwise it creates a new session. | String | null | -| autoGenerateSession | Whether the library should automatically generate a session when no session is found in the query or the cookies | Boolean | true | -| autoMountForms | Whether the library should automatically mount forms collected or not | Boolean | true | +| Property | Description | Type | Default | +|---------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------|-------------------------------------------| +| session | A valid Hellotext session which was stored previously. When not set, Hellotext attempts to retrieve the stored value from `document.cookie` when available, otherwise it creates a new session. | String | null | +| autoGenerateSession | Whether the library should automatically generate a session when no session is found in the query or the cookies | Boolean | true | +| forms | An object that controls how Hellotext should control the forms on the page. See [Forms](/docs/forms.md) documentation for more information. | Object | { autoMount: true, successMessage: true } | diff --git a/docs/forms.md b/docs/forms.md index 05842f9..b244948 100644 --- a/docs/forms.md +++ b/docs/forms.md @@ -5,6 +5,23 @@ Then let Hellotext handle building the form, collecting, validating and authenti For more information on how to create a form from the dashboard, view this [guide](https://help.hellotext.com/forms). +### Configuration + +Hellotext forms have a default configuration that can be overridden by passing an object when initializing the library. It has the following attributes by default: + +- `autoMount`: Automatically mount forms to the DOM when a `form` element with the `data-hello-form` attribute is found. Default is `true`. +- `successMessage`: Display a contextual success message when a form is submitted successfully. Default is `true`. +You can turn this off by setting it to `false`, or provide your custom success message by setting it to a string. + +```javascript +Hellotext.initialize('HELLOTEXT_BUSINESS_ID', { + forms: { + autoMount: true, + successMessage: 'Thank you for submitting the form' + } +}) +``` + ### Collection Phase Hellotext uses the `MutationObserver` API to listen for changes in the DOM, specifically new form elements being added that have the `data-hello-form` attribute.