Version 2.9.0
I’m trying to keep the state of a button when a user (or multiple users) refreshes their web browsers. Unfortunately the button is being ‘reset’ on every refresh of the browser. Is there a -OnRefresh event I can capture to read the state of the button from a text file? Or is there a better way to keep the state?
Import-Module UniversalDashboard.UDButtonLoader
Get-UDDashboard | Stop-UDDashboard
Start-UDDashboard -Port 1000 -FORCE -Dashboard (
New-UDDashboard -Title "Powershell UniversalDashboard" -Content {
New-UDButton -Id "Loading" -Text "Test" -onClick {
function Set-UDButtonStateChange {
param($Id, $Text, $Color, [Switch]$Disabled)
if ($Disabled) {
Invoke-UDJavaScript -Javascript "
document.getElementById('$($Id)').disabled = true;
document.getElementById('$($Id)').textContent = '$($Text)'"
} else {
Invoke-UDJavaScript -Javascript "
document.getElementById('$($Id)').disabled = false;
var btn = document.getElementById('$($Id)');
btn.textContent = '$($Text)';
btn.style.backgroundColor = '$($Color)'"
}
}
Set-UDButtonStateChange -Id 'Loading' -Text 'Change Text'
}
}
)