This JavaScript API is available on every page that has the widget. All methods reside in window.widgetformapi
object.
All the methods are available on widnow.widgetformapi
object.
window.widgetformapi.open(form_id_or_name: string|undefined)
- opens the widget. Can be used to open the widget manually (e.g. on button click). If form_id_or_name
passed, opens form with matching id or name (case insensitive). If no form with given form_id_or_name
was found, opens the widget as if the parameter was not passed.
window.widgetformapi.close()
- closes the widget.
window.widgetformapi.changeBubbleText(text: string|null)
- changes the text in the bubble next to the widget form. If null is passed, hides the message container.
window.widgetformapi.getConfiguration() => Website
- returns current configuration for the widget. The configuration is fetched asynchronously, thus it may return undefined
if the configuration is not fetched as the moment of a call.
window.widgetformapi.onReady((cb: (config: Website) => void))
- method allows you to register a callback function that will be executed when the configuration is ready.