Create objects using code

Is it possible to use Corvid Code to dynamically create and destroy objects on a page?

For Example:

User can choose how many catagories to add to an event (1 to infinity) changing the number will generate the required text boxes to enter the data into.

1 Like

You can use a Repeater for this, and you can configure different layouts depending on your needs.

Hi CP, I read some of your earlier posts, and, like Yisrael, I was thinking of the repeater element. Some of your earlier posts, where you were writing about creating a game or competition that needed page objects to be created or destroyed, made me think of a grid of repeaters. I don’t know if it’s done before, but you could for example create a vertical column of 10 repeaters. Each of those 10 repeaters could expand horizontally with multiple items. If each repeater has 10 horizontal items, this would lead to a 10x10 grid of elements.

To do this, it would probably be easiest to use some code. The code would give instructions to the repeaters. Each repeater item has a container which can show or hide, for example. You could also change the background color/image, or manipulate any element in the repeater item.

Someone must have thought of this before, and made some kind of game. I can image tetris with repeaters or something like that :slight_smile:

Here is some reference on setting the individual items of a repeater: https://www.wix.com/corvid/reference/$w.Repeater.html#forItems

Hi, thankyou both for your replies!
I will investigate and see if it can work.
Just for reference, I am trying to create a tournament tree that a varying size depending on the number of competitors.
This is an example taken from https://challonge.com/tournament/bracket_generator

It needs to be dynamic as the number of competitors changes how many matches, rounds etc there are. My first thought was to create all the elements as they are needed depending on competitor number, otherwise I will have to place the elements and hide the ones that aren’t needed but this will effectively mean there is an upper limit to the number of competitors.

Thanks!

I’d say do this in HTML (you can interact with HTML from Corvid) or wait and see what EditorX can do. As it stands right now anything in Corvid that requires fine-grained control of layout is a royal PITA if not impossible.

I am having some good success with using a repeater for this! But I think there might be a limitation:
Am I able to increase the seperation between each item in the Repeater more than the 100pxls it seems to allow? each round of the tournament has its own repeater, and the seperation between the items should increase for each one by a very large margin!