Created
November 29, 2018 11:07
-
-
Save AlanJenkinsVS/b51d6e3f47d8ab75121ad271588f0935 to your computer and use it in GitHub Desktop.
Using AMP to display a dropdown showing options for Results per Page
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- | |
Expect back-end src to respond with a results_per_page array of objects | |
{ | |
"items": { | |
"results_per_page" :[{ | |
"value": "10", | |
"text": "10", | |
"selected": true | |
},{ | |
"value": "50", | |
"text": "50", | |
"selected": false | |
},{ | |
"value": "100", | |
"text": "100", | |
"selected": false | |
},{ | |
"value": "all", | |
"text": "All", | |
"selected": false | |
}] | |
} | |
} | |
--> | |
<amp-list | |
layout="flex-item" | |
height="40" | |
src="/filters.json.php" | |
[src]="'/filters.json.php?<?=$initial?>"> | |
<template type="amp-mustache"> | |
{{current_items}} | |
<select on="change:AMP.pushState({ filtering: { results_per_page: event.value }, product_list: { items: { loading: true } } })"> | |
<optgroup label="Results per Page"> | |
{{#results_per_page}} | |
{{#selected}} | |
<option value="{{value}}" selected>View {{text}}</option> | |
{{/selected}} | |
{{^selected}} | |
<option value="{{value}}">View {{text}}</option> | |
{{/selected}} | |
{{/results_per_page}} | |
</optgroup> | |
</select> | |
</template> | |
</amp-list> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment