New-UDDynamic v3 PSU not updating

Can anyone explain why this V3 Dashboard with a New-UDDynamic does not update as it should? I expect as I click the button, the UDParagraph will update, but I cannot get it to work at all

New-UDPage -Name “Cards” -Content {
$Session:DisplayName = “John Smith”
New-UDDynamic -content {
New-UDCard -Id “Sync” -Title ‘DisplayName Card’ -content {
New-UDParagraph -Text $Session:DisplayName
}
}
New-UDTextbox -Id ‘txtExample’
New-UDButton -OnClick {
$Session:DisplayName = (Get-UDElement -Id ‘txtExample’).value
Show-UDToast -Message $Session:DisplayName
Sync-UDElement -Id “Sync”
} -Text “Get textbox value”
}

You need to sync the UDDynamic and not the card.

$Page = New-UDPage -Name “Cards” -Content {
$Session:DisplayName = “John Smith”
New-UDDynamic -Id 'Sync' -content {
New-UDCard -Title ‘DisplayName Card’ -content {
New-UDParagraph -Text $Session:DisplayName 
}
}
New-UDTextbox -Id ‘txtExample’
New-UDButton -OnClick {
$Session:DisplayName = (Get-UDElement -Id ‘txtExample’).value
Show-UDToast -Message $Session:DisplayName
Sync-UDElement -Id “Sync”
} -Text “Get textbox value”
}


New-UDDashboard -Title "Hello, World!" -Pages $Page
2 Likes

God so simple, many thanks I’ve made real progress today.

1 Like