Hello,
I am pretty new with Universal Dashboards and do understand some of the basics.
My question is about Event-handling and variables.
After reading documentation, experimenting, looking at other code, I have not found the answer.
The dashboard contains a checkbox and a button. When the checkbox has been selected, var $Myvar gets a new value which must be used after clicking the button.
However the button still shows the initial value of the var.
Any help is highly appreciated. Thanks in advance for your help.
Get-UDDashboard | Stop-UDDashboard
$Myvar = "Old message"
$MyDashboard = New-UDDashboard -Title "Select me" -Content {
New-UDElement -Id "CheckboxState" -Tag "span"
New-UDCheckbox -Id CheckBox -Label "Check me" -OnChange {
$Element = Get-UDElement -Id CheckBox
Set-UDElement -Id "CheckboxState" -Content $Element.Attributes["checked"]
$Myvar = "New message"
}
New-UDHeading -Size 5 -Id "ShowOnClick" -Text ""
New-UDButton -Text "Button" -OnClick {
#Set-UDElement -Id "ShowOnClick" -Content { "Button message" }
Show-UDToast -Message $Myvar
}
}
Start-UDDashboard -Dashboard $MyDashboard -Port 10000