How do you get the id from a tab that is inside a module?

I want to get the output from the tabBox() which is input$tabset1.

I have had a look at the documentation, but it seems to behave a bit differently in the module:

https://rstudio.github.io/shinydashboard/structure.html#tabbox

# module -----------------------------------------------------------------
test_ui <- function(id) {
  ns <- NS(id)
  tagList(
    box(
      width = 12,
      title = "test",
      
      # just to look at the output
      uiOutput(ns("text")),
      
      tabBox(
        id = "tabset1", # see https://rstudio.github.io/shinydashboard/structure.html#tabbox
        tabPanel("Tab1", "First tab content"),
        tabPanel("Tab2", "Tab content 2")
        )
      )
  ) 
} 

test_server <- function(id){
  moduleServer(id, function(input, output, session){
    
    # reactive variables -----------------
    rtab <- reactive(input$tabset1)
    
    # test 
    output$text <- renderUI(paste("tab: ", rtab()))
    
  }) # end module
} # end server

# app -----------------------------------------------

library(shinydashboard)
library(shiny)

ui <- dashboardPage(
  dashboardHeader(title = "test"),
  dashboardSidebar(),
  dashboardBody(
    test_ui("a")
  )
)

server <- function(input, output) {
  test_server("a")
}

shinyApp(ui, server)

I think most likely a lack of namespacing on the input you want to use

1 Like

Yes, that is it. Thanks.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.