Hi guys,
I suspect I already know the answer to this but I wanted to check before I make any changes.
I’ve got some modals with select boxes in. If I click out of the modal and then go back in again it remembers the item I have selected. Is there a way to get a modal to re-load or reset when it has been clicked out of?
My guess is the only way to do it will be to make it a persistent modal to prevent users clicking out to close and to have a cancel button which just calls ‘hide-udmodal’.
Cheers,
Tom.
I ran into this scenario again so I had another go at figuring this one out now I’ve had a bit more experienced with UD.
In case anyone else has this issue I thought I’d share my solution and hopefully it helps someone out. If you create your select inside a scriptblock and set that as a variable, then insert the scriptblock in a New-UDElement using invoke-command, the select box will reset each time the modal is opened regardless of whether hide-udmodal was called or not (i.e. if a user pressed escape or clicked out of the modal). Providing you set a session variable in the onchange event (e.g. $Session:UsefulInfo=$eventdata) then everything works as normal.
Here’s some pseudo code to help explain:
Show-UDModal -Content {
$ScriptBlock={
New-UDSelect....
}
New-UDElement -Id "WrapperElement" -Tag div -Content {
Invoke-Command -Scriptblock $ScriptBlock
}
}
1 Like