I’m trying to work out a way to have what amount to Next and Back buttons on pages that don’t un-collapse the menus on a Fixed SideNav. Best as I can tell, using New-UDLink to the next page loads the whole page, as does Invoke-UDRedirect as the -OnClick of New-UDButton, but using New-UDInput > New-UDInputAction -RedirectURL only loads the content (and URL?) but not the Header, Footer, and SideNav. I even went so far as to create an Input to redirect, hide it by ID with a Theme, and create a Button that calls JavaScript to click the button on the Input. I’ve even put together demo code below.
But is there a more elegant method that I’m completely missing? This feels like a janky workaround for walking through some simple tasks.
$Theme = New-UDTheme -Name Test -Parent Default -Definition @{
'#HiddenRedirect' = @{
display = 'none'
}
}
$Pages = @(
New-UDPage -Name 'Link' -DefaultHomePage -Content {
# This will collapse the SideNav menu
New-UDLink -Url '/Button' -Text 'UDLink'
}
New-UDPage -Name 'Button' -Content {
# This will also collapse the SideNav menu
New-UDButton -Text 'UDButton' -OnClick {
Invoke-UDRedirect -Url '/Input'
}
}
New-UDPage -Name 'Input' -Content {
# This won't collapse the SideNav menu, but is a big Form
New-UDInput -Endpoint {
New-UDInputAction -RedirectUrl '/HiddenInput'
}
}
New-UDPage -Name 'HiddenInput' -Content {
# This won't collapse the SideNav menu, but requires adding the Id of every one you use
# to the Theme as hidden, and using custom JavaScript to click the hen Input form button
New-UDInput -Id HiddenRedirect -Endpoint {
New-UDInputAction -RedirectUrl '/Link'
}
New-UDButton -Text 'Js Button for Input' -OnClick {
Invoke-UDJavaScript -JavaScript 'document.getElementById("btnHiddenRedirect").click()'
}
}
)
$Navigation = New-UDSideNav -Fixed -Content {
New-UDSideNavItem -Text 'Expanded header' -Children {
New-UDSideNavItem -Url 'Link' -Text 'Use UDLink'
New-UDSideNavItem -Url 'Button' -Text 'Use UDButton'
New-UDSideNavItem -Url 'Input' -Text 'Use UDInput'
New-UDSideNavItem -Url 'HiddenInput' -Text 'Use UDButton and hidden UDInput'
}
}
$Dashboard = New-UDDashboard -Title 'Redirect Testing' -Pages $Pages -Navigation $Navigation -Theme $Theme
Start-UDDashboard -Dashboard $Dashboard -Port 10001