Create Autocomplete template
Attributes
The following data-* attributes are required by the library to handle attributions (click events) for products/keywords/history items rendered in the autocomplete result:
data-ns-hit
This attribute should be used on clickable keyword, product, history list elements. This attribute handles submit keyword/history as search, redirect to product, analytics (if enabled) request.
Following table shows value for this attribute depending on the rendering context.
keyword
value from response.data.search.keywords
Code example:
Value example:
product
productId and url from response.data.search.products.hits
Code example:
Value example:
history
historyEnabled & historySize config. Refer Initialization
data-ns-remove-history
This attribute should be used to delete history entries in the autocomplete
To make an element delete a single history entry when clicked, add data-ns-remove-history={hit.item} to an element. In order to delete all history entries, add data-ns-remove-history="all" to clear button.
Starter templates
This section provides links to default startup templates for different rendering frameworks. These templates can be copied and customized as needed.
Last updated
Was this helpful?