Enable switching between pages without {shiny.router} #19
-
|
Referencing: https://appsilon.github.io/shiny.fluent/articles/st-sales-reps-dashboard.html#adding-shiny-router Is it possible to enable switching between pages/modules without using the In my specific use case, I am utilizing the For example, using the shiny.fluent demos provided, when defining the Since the controls (toggle, people picker, etc) need their Since the namespace id is required, I cannot define this object outside of the function in the global environment, But if the Thoughts? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
|
not sure if I need to tag people in order to get alert @marekrogala |
Beta Was this translation helpful? Give feedback.
-
|
Hi @kyle-power, thanks for reaching out! I hope these examples help. LMK if you have additional questions. Using Nav without shiny.routerIt might be slightly obscure, but you can use the library(glue)
library(shiny)
library(shiny.fluent)
handleLinkClick <- function(inputId) {
JS(glue("(e, link) => Shiny.setInputValue('{inputId}', link.key)"))
}
shinyApp(
ui = withReact(
Nav(
groups = list(
list(links = list(
list(name = 'Home', key = 'home', icon = 'Home'),
list(name = 'Appsilon', key = 'appsilon', icon = 'Accounts')
))
),
onLinkClick = handleLinkClick("link")
)
),
server = function(input, output) {
observe(showNotification(req(input$link)))
}
)Please note, that Using shiny.router with modulesPutting shiny.fluent aside, please note that you can actually use shiny.router with modules easily: library(shiny)
library(shiny.router)
helloUI <- function(id) {
ns <- NS(id)
tagList(
actionButton(ns("click"), "Say Hello")
)
}
helloServer <- function(id) {
moduleServer(id, function(input, output, session) {
observeEvent(input$click, showNotification("Hello!"))
})
}
byeUI <- function(id) {
ns <- NS(id)
tagList(
actionButton(ns("click"), "Say Bye")
)
}
byeServer <- function(id) {
moduleServer(id, function(input, output, session) {
observeEvent(input$click, showNotification("Bye!"))
})
}
router <- make_router(
route("/", helloUI("apples")),
route("bye", byeUI("bananas"))
)
shinyApp(
ui = fluidPage(
h4("Navigation"),
p(a(href = "#!/", "Hello Page")),
p(a(href = "#!/bye", "Bye Page")),
h4("Content"),
router$ui
),
server = function(input, output) {
router$server()
helloServer("apples")
byeServer("bananas")
}
) |
Beta Was this translation helpful? Give feedback.
Hi @kyle-power, thanks for reaching out! I hope these examples help. LMK if you have additional questions.
Using Nav without shiny.router
It might be slightly obscure, but you can use the
Navcomponent without shiny.router.