문제

Is it possible to perform an action if the user clicks into a particular tabPanel?

For instance, if the user clicks into tabPanel("A", ...) then display a popup saying You are viewing tab "A".

도움이 되었습니까?

해결책

tabsetPanel() will return the value assigned to the active tabPanel(). If you just want to update another output you could do something like this:

ui.R

library(shiny)    

shinyUI(basicPage( 

  textOutput("text"),
      tabsetPanel(id = "tabs",
          tabPanel("Tab A", value = "A", "This is Tab A content"),
          tabPanel("Tab B", value = "B", "Here's some content for tab B.")
  )

))

server.R

library(shiny)

shinyServer(function(input, output) {

    output$text <- renderText({paste0("You are viewing tab \"", input$tabs, "\"")})

})

but something more complicated like creating a popup would probably require making an observer and some additional custom coding...

다른 팁

If you are using shiny dashboard, input$tabBox_id will locate the active tab name. Refer to here: https://rstudio.github.io/shinydashboard/structure.html#tabbox

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top