Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

188
Views
How to refresh amp-list that its data is from amp-state

I want to update an amp-list which its data is from amp-state data.

<div>
    <amp-script layout="container" script="hello" class="sample" data-ampdevmode>

        <button id="button">Update</button>

        <amp-state id="localState">
          <script type="application/json">
            {
              "items": [{"id": 3}, {"id": 1}, {"id": 2}]
            }
          </script>
        </amp-state>

        <amp-list width="auto" height="140" layout="fixed-height" src="amp-state:localState">
          <template type="amp-mustache">
            <li>@{{id}}</li>
          </template>
        </amp-list>

    </amp-script>

    <script id="hello" type="text/plain" target="amp-script">
        document.getElementById('button').addEventListener('click', async (e) => {
            let items = [{"id": 6}, {"id": 7}, {"id": 8}];
            await AMP.setState({localState: {items: items}});

            console.log(await AMP.getState('localState'));
        });

    </script>

</div>

but when I click on the button to update, it is updating the AMP state, but it doesn't show the updated data on the page.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!