Skip to main content
MindTouch Success Center

Search-in-place Touchpoint Events

Applies to:
MindTouch (current)
Role required:
Admin

Events

mindtouch-web-widget:search:ready

Fired when the search widget is created. The event data contains the following parameters:

  • embedId <String> - The ID string of the widget that uniquely identifies it
 document.addEventListener('mindtouch-web-widget:search:ready', ({ data }) => {
    const embedId = data.embedId;
});

mindtouch-web-widget:search:loaded

Fired when the search widget is loaded. The event data contains the following parameters:

  • embedId <String> - The ID string of the widget that uniquely identifies it
  • widget <Object> - The object interface to the widget that contains the properties and/or functions listed below
document.addEventListener('mindtouch-web-widget:search:loaded', ({ data }) => {
    const embedId = data.embedId;
    const widget = data.widget;
});

mindtouch-web-widget:search:search-completed

Fires after a search has been completed, but before search results have been displayed. The event data contains the following parameters:

  • embedId <String> - The ID string of the widget that uniquely identifies it
  • results <Array<Object>> - An array of search result objects that were returned
document.addEventListener('mindtouch-web-widget:search:search-completed', ({ data }) => {
    const embedId = data.embedId;
    const results = data.results;
    results.forEach((result) => {
        console.log(result.uri);
    });
});

Properties

searchQuery <String>

  • Gets the search query value
  • Sets the search query value and performs a search. Set as a JavaScript object property or as adata-search-querydata attribute on the mindtouch/embed script HTML tag
document.addEventListener('mindtouch-web-widget:search:loaded', ({ data }) => {
    const widget = data.widget;
    widget.searchQuery = '{example-search-query}';
});
<script async="async" src="https://success.mindtouch.com/@embed/{guid}.js"></script>
<script type="mindtouch/embed" id="mindtouch-embed-{guid}" data-search-query="{example-search-query}"></script>

searchInput <String|Element>

  • Gets the DOM element assigned to listen for search query input
  • Sets the HTML form input element to use as the search query source. Any form input outside of the widget interface can be used to control the widget search behavior. This may be an element selector string or a DOM element. Set as a JavaScript object property or as a data-search-inputdata attribute (element selector string only)
document.addEventListener('mindtouch-web-widget:search:loaded', ({ data }) => {
    const widget = data.widget;
    
    // element selector string example
    widget.searchInput = '{example-selector}';
    
    // DOM element example
    widget.searchInput = document.querySelector('{example-selector}');
    
    // get the current search input element
    const foo = widget.searchInput;
});
<script async="async" src="https://success.mindtouch.com/@embed/{guid}.js"></script>
<script type="mindtouch/embed" id="mindtouch-embed-{guid}" data-search-input="{example-selector}"></script>
  • Was this article helpful?