I feel like I’m missing something obvious here. I need a simple button to refresh the current page.
Something akin to:
New-UDButton -Text 'Refresh' -OnClick {
New-UDHtml -Markup '"window.location.reload();">'
}
Something like this:
<button value="Refresh Page" onClick="window.location.reload();">
Seems like I’m missing something obvious.
You can’t execute Javascript (as far as I know) from these OnClick scriptpoint handler.
However, if you create your entire button using New-UDHtml, these constraints disappears.
New-UDHtml -Markup '<button class="btn ud-button" type="button" onClick="window.location.reload();">Refresh</button>'
For the classes, I created a standard UD-Button first, looked at its classes from the browser inspector view so I knew which class to choose for my custom button.
2 Likes
If anyone else comes across this thread while searching, I did this via the following method which I found cleaner:
New-UDButton -Text ‘Refresh’ -OnClick {
invoke-udredirect -url “/pagename”
}
3 Likes
I had the same issue and found you can get the current location from the supplied $headers variable.
So at the top of the script I do:
$loc=($Headers.windowlocation)
And lateron where needed:
New-UDButton -id "cancel" -text "cancel" -OnClick {
invoke-udredirect -url "$loc"
}