Genie Discord forum

Author AvatarJuliane Müller-Sielaff
2/14/2023, 10:00:19 AM

Hello, when clicking on a button, a new visual element shall be added to the html file as well as the html structure is dependent on the structure of a julia object (the html file shall visually represent the object structure and allow for modification).

Is there a way to add visual elements programatically?

Author AvatarPere
2/14/2023, 7:16:10 PM

if you're ok with just hiding the element until you want to display it, you could use some inline css

where in the julia code you have @out displayvar = "none"

Author AvatarPere
2/14/2023, 7:17:49 PM

Also, in Genie Builder you can use the "condition" binding to set an element's visibility

Author AvatarJuliane Müller-Sielaff
2/15/2023, 8:11:54 AM

Hello Pere, thanks for the quick reply! 🙂

Unfortunately, this doesn't fulfill my wishes. I have a julia object with a predefined structure, e.g.,

struct OverviewCard header::Header body::Body CTA::Maybe{Vector{AbstractButton}} id::String footer::Footer end

I want to represent this structure in the html. So for this example, for each element (header, body, footer, CTA), a div element shall be generated in the html. Furthermore, the CTA div includes again as many divs as the vector of AbstractButtons include. Is this possible with Genie Builder? How can I implement this?

Author Avataressenciary
2/20/2023, 8:30:17 AM

best approach would be to generate the HTML content dynamically - do you have an example of an OverviewCard with data?

Author Avatarhhaensel
3/7/2023, 11:58:59 PM

You should use @recur for a series of elements and define a template. You could get some inspiration in the editable tree demo https://github.com/GenieFramework/StippleDemos/blob/master/ReactiveTools%20API/EditableTree.jl or in the chatmessage demo of the chatmessage PR https://github.com/GenieFramework/StippleUI.jl/pull/87#issuecomment-1415519757