How to create multiple copies of html item using javascript?

I would like to make a call to a REST API that will return a variable number of items that I would like to display in a list.

So I would like to format an item, then make copies of it. Additionally, I want them to be able to click on either of two buttons on this item, to show different options to the user after the click.

I could use a Repeater… but if they click on either of two buttons on this item, I want to show different options to the user. And I think that I couldn’t just change one item of a repeater like that. Or can I?

Is there a different way to do this copy and paste of an element on a page?

Thank you!

Each item of a Repeater is its own entity, and the components in the repeater item have their own context. If you connect the Repeater and its elements to a dataset, the component context is automatically handled. For example:


The Submit action for that button will “submit” for that Repeater item.

If you set the Repeater’s content using the .data property, then you will need to handle the context yourself. In the onItemReady() event handler , you can declare/define button event handlers, so that button clicks would have the context of that repeater item’s data.

See the Repeater API for more details.

1 Like