At the moment the app ends when the user clicks on a button Q
. I would like this app to end when the user clicks Quit
on the navbar. Unfortunately I can't figure out how to do this. Will be thankful for any help!
EDIT:
It would be great to know how to shift Quit
tab to the right :)
ui <- shinyUI(navbarPage(title = "Test",
tabPanel(title = "Content",
actionButton(inputId = "quit", label = "Quit")
),
tabPanel(title = "Quit", icon = icon("circle-o-notch"))
)
)
server <- shinyServer(function(input,output) {
observe({
if (input$quit == 1) stopApp()
})
})
shinyApp(ui, server)
The solution for your problem is to create an id for the navbar, with that, you can call observer like you did but changing the input. The only problem is to identificate that you need to create a new id for the navbarPage.
shinyApp(
ui = navbarPage(title = "Test", id="navbar",
tabPanel(title = "Content"),
tabPanel(title = "Quit", value="stop", icon = icon("circle-o-notch"))
), #Close UI
server = function(input,output,session) {
observe({
if (input$navbar == "stop")
stopApp()
})
} #Close server
) #Close shinyApp
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With