I am wanting to access the id passed into a shiny modules UI component and the callModule
inside the corresponding server component of the module. My intention is to use the id provided by the user to add a title to a pop up modal.
library(shiny)
fooModuleUI <- function(id) {
ns <- NS(id)
list(
actionButton(inputId = ns("show"), label = "Show")
)
}
fooModule <- function(input, output, session) {
# I want to be able to access the id of the module here so that I can use it
# to construct the title to the modal
observeEvent(input$show, {
showModal(
modalDialog(
title = paste0("Add ", "Module id here"), # Want module id here
footer =
div(
modalButton("Cancel"),
actionButton("insert", "Save")
)
)
)
})
}
ui <- shiny::fluidPage(
fooModuleUI("test")
)
server <- function(input, output, session) {
callModule(fooModule, "test")
}
shiny::shinyApp(ui, server)