October 2017
Intermediate to advanced
370 pages
8h 57m
English
The first thing we'll do is remove the form and the submit-success elements that we used last time, and instead use amp-list to fetch the search results. We'll keep the input field, and when the input changes, we'll set an AMP state property with the keywords entered. We'll bind this property to the amp-list src URL that will fetch the search results from the server. The search input field will look like this:
<input name="keywords" type="text" placeholder="Search" on="input-debounced:AMP.setState({keywords: event.value})"><input type="submit" value="">
The magic happens in the on attribute. We're using an event we haven't seen before: input-debounced. This event is just like the change event, except ...
Read now
Unlock full access