Skip to main content
NICE CXone Expert

Our office will be closed on Monday, December 26th and January 2nd, for Christmas and New Years.

Expert Success Center

Touchpoint Factory Events

Applies to:
MindTouch (current)
Role required:
Admin

Events

mindtouch-web-widget:factory:loaded

Fired when the widget factory is loaded. The event data contains the following properties:

Name Type
widget.load function
document.addEventListener('mindtouch-web-widget:factory:loaded', ({ data }) => {

    // programmable factory interface contains properties and functions
    const factory = data.widget;
});

Properties

load

load(string embedId) : Promise

Loads a created widget that has not been autoloaded and returns a promise to be resolved when the widget loading has completed. This function accepts the following parameters:

Name Type Description
embedId string The embed id of the widget to load
<script async="async" src="https://foo.example.com/@embed/f21e8d489c198a5e64bf073c8e65c2405e0c0f0241a8b9b78fbc59abe5856b2f.js"></script>

<!-- data-autoload="false" instructs the factory not to autoload this widget -->
<script type="mindtouch/embed" id="mindtouch-embed-f21e8d489c198a5e64bf073c8e65c2405e0c0f0241a8b9b78fbc59abe5856b2f" data-autoload="false"></script>
document.addEventListener('mindtouch-web-widget:factory:loaded', ({ data }) => {

    // assign the factory and wait for the widget to be created
    const factory = data.widget;
    document.addEventListener('mindtouch-web-widget:search:ready', ({ data }) => {
    
        // NOTE: widget loaded by ID must be in a "ready" state and not already loaded
        factory.load(data.embedId);
    });
});

The widget on-demand loading pattern can be used to control the order in which widgets are loaded in an integration. In this example, the Factory, Search-in-Place, and Sign-In Touchpoints all work together in order to ensure search functionality is only available to an authenticated MindTouch user.

document.addEventListener('mindtouch-web-widget:factory:loaded', ({ data }) => {
  const factory = data.widget;
  document.addEventListener('mindtouch-web-widget:search:ready', ({ data }) => {
    
    // get unloaded search touchpoint id
    const searchEmbedId = data.embedId;
    document.addEventListener('mindtouch-web-widget:login:loaded', ({ data }) => {
      if(!data.user.anonymous) {
        
        // user is already signed in, load search touchpoint by id
        factory.load(searchEmbedId);
        return;
      }
      document.addEventListener('mindtouch-web-widget:login:auth-changed', ({ data }) => {
        
        // wait for user to sign in before loading search touchpoint by id
        if(!data.user.anonymous) {
          factory.load(searchEmbedId);
        }
      });
    });
  });
});
  • Was this article helpful?