Reputation: 303
I am trying to set location filter in the form by using amp-list, I am trying to do in the following way:
<amp-list width="auto"
height="35"
layout="fixed-height"
src="<?php echo plugins_url
( 'assets/json/locations.json', __FILE__ ) ?>">
<template type="amp-mustache">
<select id="locations"
name="location"
on="change:
AMP.setState({
locations: dropdown.items.filter(x => x == event.value)
})"
>
<option value="">Choose a location</option>
{{#items}}
<option value="{{.}}">{{.}}</option>
{{/items}}
</select>
</template>
</amp-list>
and my json file is like this:
{"items":["Bangalore","Indore","Long Island","Lucknow","New Delhi","New Jersey"]}
The current amp-list rendering is below the keyword text input box
I have read documentation but I am unable to figure it out, please help. I want to have all locations inside single 'choose location' drop-down
Upvotes: 1
Views: 224
Reputation: 4288
You have to move the <select>
outside the amp-list:
<select id="locations" name="location" on="change:
AMP.setState({
locations: dropdown.items.filter(x => x == event.value)
})">
<option value="">Choose a location</option>
<amp-list width="auto" height="35" layout="fixed-height" src="<?php echo plugins_url
( 'assets/json/locations.json', __FILE__ ) ?>">
<template type="amp-mustache">
<option value="{{.}}">{{.}}</option>
</template>
</amp-list>
</select>
Upvotes: 1