Product: PowerShell Universal
Version: 5.6.9
I have a checkbox set to enable or disable other components. The checkbox will enable the select and textbox, but it won’t disable them.
Made an app with just those components to makes sure it wasn’t something else interfering and I get the same result. I do get the UDToasts so I know the If statement is working, it’s just the Set-UDElement that isn’t working.
New-UDApp -Content {
New-UDCheckBox -id "Checkbox" -Label "Checkbox" -OnChange {
if ($true -eq $body){
show-udtoast -message $body
set-udelement -id "select" -properties @{disabled = $false}
set-udelement -id "textbox" -properties @{disabled = $false}
}
Elseif ($false -eq $body) {
show-udtoast -message $body
set-udelement -id "select" -properties @{disabled = $true}
set-udelement -id "textbox" -properties @{disabled = $true}
}
}
New-UDHtml -Markup "<br>"
new-udselect -id "select" -label "Select" -option {
new-udselectoption -name "name" -value "name"
} -OnChange {
show-udtoast -message $EventData[0] -Duration 5000
} -disabled
New-UDHtml -Markup "<br>"
New-UDTextbox -id "textbox" -label "textbox" -disabled
}
I also tried setting the disabled switch to a variable, updating that, and putting those components into a dynamic, but that gives me the same result. Checking the box will enable, but unchecking with not disable the components.
New-UDApp -Content {
$session:SelectDisabled = $true
$session:TextDisabled = $true
New-UDCheckBox -id "Checkbox" -Label "Checkbox" -OnChange {
if ($true -eq $body){
show-udtoast -message $body
$session:SelectDisabled = $false
$session:TextDisabled = $false
sync-udelement "dynamic"
}
Elseif ($false -eq $body) {
show-udtoast -message $body
$session:SelectDisabled = $true
$session:TextDisabled = $true
sync-udelement "dynamic"
}
}
New-UDHtml -Markup "<br>"
new-uddynamic -id "dynamic" -Content {
new-udselect -id "select" -label "Select" -option {
new-udselectoption -name "name" -value "name"
} -disabled:$session:SelectDisabled
New-UDHtml -Markup "<br>"
New-UDTextbox -id "textbox" -label "textbox" -disabled:$session:TextDisabled
}
}