Can I dynamically add Element to CollapsibleItem

I want to push a button inside a collapsible item and add another item to the collapsible. The button shows up but it doesn’t add the item to the collapsible.

    $inputArgCollapsible = New-UDCollapsible -Items {
        New-UDCollapsibleItem -Title  "User Specified Input Arguments (optional)" -Id "frogger" -Icon arrow_circle_right -Content {
            New-UDButton -Text "AIC"  -OnClick (
                New-UDEndpoint -Endpoint {
                    Add-UDElement -ParentId "frogger" -Content {
                        New-UDCheckbox -FilledIn -Label "Requires Admin to Execute Successfully?" 
                    }
                }
            )
        }
    }

Hi @clr2of8, and welcome to the UD Forums!

Sadly, as New-UDCollapsible is static, ie Executed once and cannot be updated unless an parent element is dynamic.

To archieve makeshift dyanmic functinality, you’d need to wrap an endpoint around your Collapsible, and update said endpoint. Note: this will not be a visually appealing solution, as it would minimize all the currently open collapsible items, and remove focus unless you manually use Select-UDElement

If this is a feature you’d like to see, i’d reccommend you to submit an enhancement request on github.

Thank you for the quick response. It helps to know that I wasn’t doing something wrong. I’ll just figure out a way to do it without the collapsible, thx.

No worries @clr2of8 !
If you’re fresh, i’d reccomend reading @psDevUK’s blogpost regarding Endpoints vs Content

If you want any guidance, shout and i’ll try to point you into the right direction!

2 Likes