Refresh amp-list content on button click

487 Views Asked by At

I have a page that generates random numbers for a user. On page load, it will generate data and I can handle this much with amp-list. What I want is to have a button where the user can generate new data. Think of it like a bingo number generator. Page loads and presents the user with a 6. They want a new number, how can this be done?

I was thinking I could force the page to reload by linking to itself. So the "new number" button would actually just be a url link to the exact same page and this will generate a new number on page load. Using a div with an ID i can provide #randomnumber in the URL and it will go straight to this position.

Im a bit worried about this though as Google might see this as me attempting to inflate viewing numbers to get more ad revenue and what not. Is there a better way to go about this?

1

There are 1 best solutions below

1
Trey Copeland On

You can use changeToLayoutContainer to refresh data in amp-list. Give it an ID and reference that in your on

Example:

<button on="list.changeToLayoutContainer()">Show Grid</button>