Collapse New-UDCollapsibleItem from Set-UDelement

Hello,

Is it possible to Collapse the New-UDCollapsibleItem via Set-UDelement?

@kdf2883

Did you ever figure this out?

I dont think this would work dynamically with set-udelement as its static content and only run once on page load.
To acheive this you would have to wrap the whole thing inside a dynamic element, and then set content/update/replace that.
Alternativly, you could just change the -active property on your collapsible item, and reload/refresh the page but this may not work for everyone - depends what you’re page is doing.

Example, if your page is an endpoint (or just wrap the collapsible in one)
This code will produce a collapsible set, with a button that toggles all items to collapse or open:

New-UDHtml -markup "STATE: $($session:CI_active)"

if($null -eq $session:CI_active){

    $CI_active = $true #default if session var is not set

}else{

    $CI_active = $session:CI_active

}

New-UDCollapsible -Id "CI" -Items {

    New-UDCollapsibleItem -Id "CI_1" -Title "Item 1" -Icon arrow_circle_right -Active:$CI_active -Content {

        "Some content"

    }

    New-UDCollapsibleItem -id "CI_2" -Title "Item 2" -Icon arrow_circle_right -Active:$CI_active -Content {

        "Some content"

    }

}

new-udbutton -Text "collapse" -OnClick {

    if($session:CI_active -eq $true){

        $session:CI_active = $false

    }elseif($session:CI_active -eq $false){

        $session:CI_active = $true

    }elseif($null -eq $session:CI_active){

        $session:CI_active = $false

    }

    invoke-udjavascript -JavaScript "window.location.reload();"

}