Articles in this section
Category / Section

How to Launch a Help Widget on Button Click

Published:

The widget can be customized to appear when a customer clicks a button or link on your website or a product.

To open the widget on external button or link, put the following code example before the widget embed code:

<button type="openWidgetPopup()"> Contact Us</button>

  <script>
           function openWidgetPopup() {
                BolddeskWidget("open", "popup");
           }
</script>

<script>
             window.BolddeskWidgetConfig = {
                   created: (args) => {
                       // When the widget is rendered, the created event will be triggered.
                  }
            }
</script>

 

Bind onclick event for button or link, then call the widget API to open the popup BolddeskWidget(“open, “popup”).

Note: The function BolddeskWidget(“open, “popup”) will trigger the widget to show.

The following properties can be found in the created event argument:

{
      type: widget | form,
      id: Widget Id | Web form Id,
      name: Widget Name | Webform Name
}

Note: You can predict the widget rendered based on the ID and name of the fields if multiple widgets are rendered on the same page.

How to hide launcher button

Add the following code example and set the hideLauncher to true, to hide the widget when the page loads. By doing this, the launcher will not be shown, and a widget popup appears when an external button or link is clicked.


<script>
             window.BolddeskWidgetConfig = {
                             widget: {
                                           hideLauncher: true
                             }
              }
</script>

Note: You can also call the BolddeskWidget(“hide, “launcher”) widget API to hide the launcher button

The sample page that shows a widget popup when an external button is clicked.

image.png

Was this article useful?
Like
Dislike
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied