Autosuggest
.autosuggest
An input type with autosuggest function. Autosuggest must be activated on the form tag in order
to automatically submit the form when clicking or pressing enter button after selecting a suggestion.
Needed to adjust the autosuggest function to your needs, with data-config
attribute you will be able
to override some settings.
suggestUrl
is needed to point the autosuggest to feed itself The following properties are optional:limit
, defaults to5
minLength
, defaults to1
hint
, defaults totrue
highlight
, defaults totrue
Markup
<form class="searchForm autosuggest"
action="/zoeken/search"
method="GET"
data-controller="generic/ui/Autosuggest"
data-config="{
"suggestUrl": "https://gateway.apiportaltst.ns.nl/zoeken-mock/nl/suggest?q=",
"suggestHeaders": {"Ocp-Apim-Subscription-Key": "30d51d78af8b410faf42fa3ea2439a42"},
"apiType": "searchv2",
"displayValue":"text",
"submitValue":"text",
"highlight":"true",
"limit": 5,
"minLength": 1,
"extraEventData": {
"interaction_location": "identifier_for_analytics"
}
}">
<label for="searchField" class="alt">Zoeken</label>
<div class="searchForm__field">
<input id="searchField" name="q" type="search" class="searchField" placeholder="Waar kunnen we u mee helpen?" autocomplete="off" />
<div class="searchForm__clear">
<a href="javascript:void(0)" class="clearButton clearButton--grey">
<span class="icon">
<span class="alt">Veld leegmaken</span>
</span>
</a>
</div>
</div>
<div class="searchForm__submit">
<button type="submit" class="button">
Zoeken
</button>
</div>
</form>