Skip to content

Async Data

Loads a data from a remote URL and renders it into a list element via useAsyncData(listEl).

Activate

Async Data is activated by adding the data-src attribute on the list element.

html
<input id="asyncFilter" placeholder="Search fruits" />

<ul filter="asyncFilter" data-src="/fruits.json" data-template="<li>{{name}}</li>">
  <!-- Data will be populated here -->
</ul>

Method

useAsyncData(listEl)

ParameterTypeDescription
listElHTMLElementThe list element to render list items into.

Options

AttributeDescription
data-srcThe URL from which to fetch dynamic data.
data-templateThe HTML template used to render each fetched item.
data-loaderThe element to show or hide while data is being fetched.

Released under the MIT License.